forked from parpalak/i.upmath.me
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgruntfile.js
125 lines (122 loc) · 2.57 KB
/
gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
module.exports = function(grunt) {
grunt.initConfig({
concat: {
main: {
src: [
'bower_components/autosize/dist/autosize.js',
'bower_components/Stickyfill/dist/stickyfill.min.js',
'bower_components/ilyabirman-likely/release/likely.js',
'www/js/init_editor.js'
],
dest: 'www/js/scripts.js'
}
},
uglify: {
main: {
files: {
'www/js/scripts.min.js': '<%= concat.main.dest %>'
}
}
},
copy: {
main: {
files: [
// includes files within path
{
expand: true,
src: [
'bower_components/jquery/dist/jquery.min.js'
],
dest: 'www/js/',
filter: 'isFile',
flatten: true
}
]
}
},
cssmin: {
target: {
src: [
'www/css/style.css',
'bower_components/ilyabirman-likely/release/likely.css'
],
dest: 'www/css/style.min.css'
}
},
fingerprint: {
assets: {
src: [
'www/js/*.js',
'www/css/*.css'
],
filename: 'fingerprint.php',
template: "<?php define('FINGERPRINT', '<%= fingerprint %>'); ?>"
}
},
shell: {
gzipJS: {
command: [
'gzip -cn6 www/js/scripts.min.js > www/js/scripts.min.js.gz',
'gzip -cn6 www/js/jquery.min.js > www/js/jquery.min.js.gz',
'gzip -cn6 www/css/style.min.css > www/css/style.min.css.gz'
].join(' && ')
},
gzipPublic: {
command: 'gzip -cn6 www/latex.js > www/latex.js.gz'
}
},
replace: {
example: {
src: ['src/latex.js'],
dest: 'www/latex.js',
replacements: [{
from: 'tex.s2cms.ru',
to: __dirname.split('/').pop()
}]
}
},
"file-creator": {
"basic": {
"host.php": function(fs, fd, done) {
fs.writeSync(fd, "<?php define('TEX_HOST', '" + __dirname.split('/').pop() + "'); ?>");
done();
}
}
},
watch: {
scripts: {
files: ['www/js/*.js', 'www/css/*.css'],
tasks: ['concat', 'uglify', 'fingerprint'],
options: {
spawn: false
}
},
src: {
files: ['src/latex.js'],
tasks: ['replace', 'shell:gzipPublic'],
options: {
spawn: false
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-fingerprint');
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-text-replace');
grunt.loadNpmTasks('grunt-file-creator');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', [
'concat',
'uglify',
'copy',
'cssmin',
'replace',
'shell',
'fingerprint',
'file-creator'
]);
};