-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathgruntfile.js
135 lines (132 loc) · 3.29 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
126
127
128
129
130
131
132
133
134
135
module.exports = function(grunt) {
grunt.initConfig({
concat: {
main: {
src: [
'public_html/src/js/*.js'
],
dest: 'public_html/dist/js/scripts.js'
},
vendors: {
src: [
'node_modules/markdown-it/dist/markdown-it.min.js',
'node_modules/markdown-it-sub/dist/markdown-it-sub.min.js',
'node_modules/markdown-it-sup/dist/markdown-it-sup.min.js',
'node_modules/LDT/lib/TextareaDecorator.js',
'node_modules/file-saver/dist/FileSaver.min.js',
'node_modules/draggabilly/dist/draggabilly.pkgd.min.js',
'public_html/lib/highlight.js/highlight.pack.js',
'public_html/lib/indent-textarea.4.0.0.js'
],
dest: 'public_html/dist/js/vendors.js'
}
},
uglify: {
main: {
src: ['<%= concat.main.dest %>'],
dest: 'public_html/dist/js/scripts.min.js'
},
vendors: {
src: ['<%= concat.vendors.dest %>'],
dest: 'public_html/dist/js/vendors.min.js'
}
},
dataUri: {
main: {
src: [
'public_html/src/css/editor.css'
],
dest: "public_html/dist/css/",
options: {
target: ['*/i/*.*'],
maxBytes : 5000,
}
}
},
cssmin: {
main: {
src: [
'node_modules/LDT/lib/TextareaDecorator.css',
'public_html/lib/highlight.js/solarized-light.css',
'<%= dataUri.main.dest %>/editor.css'
],
dest: 'public_html/dist/css/style.min.css'
}
},
fingerprint: {
main: {
src: 'public_html/dist/js/scripts.min.js',
filename: 'public_html/dist/js/scripts.min.js.md5'
},
vendors: {
src: 'public_html/dist/js/vendors.min.js',
filename: 'public_html/dist/js/vendors.min.js.md5'
},
css: {
src: 'public_html/dist/css/style.min.css',
filename: 'public_html/dist/css/style.min.css.md5'
},
link: {
src: 'public_html/dist/css/style.min.css',
filename: 'public_html/dist/css/style.min.css.html',
template: '<link rel="stylesheet" href="/dist/css/style.min.css?<%= fingerprint %>">'
}
},
shell: {
gzipJS: {
command: [
'gzip -cn6 <%= uglify.main.dest %> > <%= uglify.main.dest %>.gz',
'gzip -cn6 <%= uglify.vendors.dest %> > <%= uglify.vendors.dest %>.gz'
].join(' && ')
},
gzipCSS: {
command: [
'gzip -cn6 <%= cssmin.main.dest %> > <%= cssmin.main.dest %>.gz',
].join(' && ')
}
},
processhtml: {
error: {
src: 'src/404.html',
dest: 'public_html/404.html'
},
news: {
src: 'src/whatsnew.html',
dest: 'public_html/whatsnew.html'
},
},
watch: {
scripts: {
files: ['public_html/src/js/*.js'],
tasks: ['concat:main', 'uglify:main', 'fingerprint:main', 'shell:gzipJS'],
options: {
spawn: false
}
},
styles: {
files: ['public_html/src/css/*.css'],
tasks: ['dataUri', 'cssmin', 'fingerprint:css', 'fingerprint:link', 'shell:gzipCSS'],
options: {
spawn: false
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-fingerprint');
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-data-uri-advanced');
grunt.loadNpmTasks('grunt-processhtml');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', [
'concat',
'uglify',
'dataUri',
'cssmin',
'shell',
'fingerprint',
'processhtml',
]);
};