官网:http://www.gruntjs.org/
发觉利用grunt打包压缩代码实在太方便了,以下是一个简单例子,更多实例详见官网
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
|
/** * Created with JetBrains WebStorm.
* User: EX-ZHOULINGFENG001
* Date: 14-1-9
* Time: 上午10:46
* To change this template use File | Settings | File Templates.
*/
/* * cmd * grunt concat * grunt uglify * grunt cssmin */
module.exports = function (grunt) {
grunt.initConfig({
concat : {
options: {
separator: ‘;‘
},
dist: {
src: [ ‘src/js/common.js‘ , ‘src/js/index.js‘ ],
dest: ‘concatJs/allJs.js‘
}
},
uglify: {
options: {
mangle: true
},
my_target: {
files: {
‘minJs/allJs.min.js‘ : [ ‘src/js/common.js‘ , ‘src/js/index.js‘ ]
}
}
},
cssmin: {
combine: {
files: {
‘minCss/allCss.css‘ : [ ‘src/css/common.css‘ , ‘src/css/index.css‘ ]
}
}
}
});
grunt.loadNpmTasks( "grunt-contrib-concat" );
grunt.loadNpmTasks( "grunt-contrib-cssmin" );
grunt.loadNpmTasks( "grunt-contrib-uglify" );
} |