forked from demun/grunt-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
305 lines (280 loc) · 8.14 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
module.exports = function(grunt) {
'use strict';
// 자동으로 grunt 태스크를 로드합니다. grunt.loadNpmTasks 를 생략한다.
require('load-grunt-tasks')(grunt);
// 작업시간 표시
require('time-grunt')(grunt);
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
banner: '/*!\n' +
' ======================================================================== \n' +
' * Project : <%= pkg.name %>(<%= pkg.description %>) v<%= pkg.version %>\n' +
' * Publisher : <%= pkg.make.publisher %> (<%= pkg.make.email %>), (<%= pkg.make.blog %>)\n' +
' * Build : <%= grunt.template.today("yyyy-mm-dd") %>\n' +
' * License : <%= pkg.license.type %> (<%= pkg.license.url %>)\n' +
' ======================================================================== \n' +
' */\n',
// html task
includes: {
build: {
cwd: 'app/docs/html/',
src: ['**/*.html'],
dest: 'dist',
options: {
flatten: true,
// debug: true,
includePath: 'app/docs/include/'
}
}
},
htmlhint: {
options: {
htmlhintrc: 'grunt/.htmlhintrc'
},
dist: 'dist/**/*.html'
},
// css task
less: {
dist: {
options: {
banner: '<%= banner %>',
dumpLineNumbers : 'comments'
},
src: 'app/less/style.less',
dest: 'app/css/style.css'
},
},
// sass: {
// dist: {
// files: {
// 'widgets.css': 'test.scss'
// }
// }
// }
// sass: { // Task
// options: { // Target options
// style: 'expanded'
// },
// dist: {
// src: 'app/sass/test.scss',
// dest: 'app/css/test.css'
// }
// },
csslint: {
options: {
csslintrc: 'grunt/.csslintrc'
},
dist: {
src: 'app/css/style.css'
}
},
autoprefixer: {
options: {
browsers: [
'Android 2.3',
'Android >= 4',
'Chrome >= 20',
'Firefox >= 24', // Firefox 24 is the latest ESR
'Explorer >= 8',
'iOS >= 6',
'Opera >= 12',
'Safari >= 6'
]
},
dist: { // app -> dest 이동
src: 'app/css/style.css',
dest: 'dist/css/style.css'
}
},
csscomb: {
options: {
config: 'grunt/.csscomb.json'
},
dist: {
src: 'app/css/style.css',
dest: 'dist/css/style.css'
}
},
cssmin: {
options: {
// compatibility: 'ie8',
keepSpecialComments: 1,
// default - '!'가 붙은 주석은 보존,
// 1 - '!'가 붙은 주석 중 첫번째 주석만 보존
// 0 - 모든 주석 제거
// noAdvanced: true,
},
dist: {
src: 'dist/css/style.css',
dest: 'dist/css/style.min.css'
}
},
// javascript task
jshint: {
options: {
jshintrc: 'grunt/.jshintrc',
force: true, // error 검출시 task를 fail 시키지 않고 계속 진단
reporter: require('jshint-stylish') // output을 수정 할 수 있는 옵션
},
grunt: {
src: ['Gruntfile.js']
},
dist: {
expand: true,
cwd: 'app/js/site',
src: ['*.js'],
dest: 'app/js/site'
}
},
concat: {
options: {
banner: '<%= banner %>'
},
dist: {
src: 'app/js/site/*.js',
dest: 'dist/js/site.js'
}
},
uglify: {
options: {
banner: '<%= banner %>'
},
dist: {
src: 'dist/js/site.js',
dest: 'dist/js/site.min.js'
}
},
// others task
imagemin: {
options: {
title: 'Build complete', // optional
message: '<%= pkg.name %> build finished successfully.' //required
},
dist: {
files: [{
expand: true,
cwd: 'app/images/',
src: '**/*.{png,jpeg,jpg,gif}',
dest: 'dist/images/'
}]
}
},
clean: {
dist: {
files: [{
dot: true,
src: [
'app/css',
'dist/**/*'
]
}]
},
},
copy: {
dist: {
files: [
// fonts
{
expand: true,
cwd: 'app/fonts/',
src: '**',
dest: 'dist/fonts/'
},
// js/lib
{
expand: true,
cwd: 'app/js/lib',
src: ['*.js'],
dest: 'dist/js/lib'
}
]
}
},
concurrent: {
options: {
logConcurrentOutput: true
},
dist: [
'copy',
'imagemin'
]
},
// watch task
watch: {
options: {livereload: true},
gruntfile: {
files: ['Gruntfile.js'],
tasks: ['newer:jshint:grunt']
},
html: {
files: ['app/docs/**/*.html'],
tasks: ['htmlhint','includes']
},
less: {
files: ['app/less/**/*.less'],
tasks: ['less','csslint','autoprefixer','csscomb','concat']
},
js: {
files: ['app/js/**/*.js'],
tasks: ['newer:jshint:dist','concat','uglify']
},
img: {
files: ['app/images/**/*.{gif,jpeg,jpg,png}'],
tasks: ['newer:imagemin']
},
},
connect: {
server: {
options: {
port: 9000,
hostname: 'localhost',
livereload: 35729,
// keepalive: true,
base: 'dist',
open: 'http://<%= connect.server.options.hostname %>:<%= connect.server.options.port %>/category1/page-02.html'
}
}
},
});
// server
grunt.registerTask('serve', function (target) {
if (target === 'dist') {
return grunt.task.run(['connect', 'watch']);
}
grunt.task.run([
'default',
'connect',
'watch'
]);
});
// html task
grunt.registerTask('html', [
'htmlhint',
'includes'
]
);
// css task
grunt.registerTask('css', [
'less',
'csslint',
'autoprefixer',
'csscomb',
'cssmin'
]
);
// javascript task
grunt.registerTask('js', [
'newer:jshint',
'concat',
'uglify'
]
);
grunt.registerTask('default', [
'clean:dist',
'html',
'css',
'js',
'concurrent'
]
);
};