-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgruntfile.js
More file actions
126 lines (120 loc) · 3.45 KB
/
gruntfile.js
File metadata and controls
126 lines (120 loc) · 3.45 KB
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
/**
* @file 构建文件
* @author AceMood
* @email zmike86@gmail.com
*/
var files = [
'lib/utils.js',
'lib/dom-script.js',
'lib/dom-css.js',
'lib/path.js',
'lib/Module.js',
'lib/AnonymousModule.js',
'lib/core.js',
'lib/event.js',
'lib/kernel.js'
];
module.exports = function(grunt) {
grunt.initConfig({
clean: ['dist/*'],
jshint: {
files: files,
options: {
curly: true,
eqeqeq: true,
es3: true,
maxlen: 100,
nonew: true,
freeze: true,
asi: true,
globals: {
document: true
}
}
},
concat: {
options: {
separator: '',
stripBanners: false,
nonull: true
},
dev: {
src: ['lib/intro.js'].concat(files).concat(['lib/log.js', 'lib/outro.js']),
dest: 'dist/kernel.debug.js'
},
pro: {
src: ['lib/intro.js'].concat(files).concat(['lib/outro.js']),
dest: 'dist/kernel.src.js'
}
},
uglify: {
options: {
report: 'gzip',
sourceMap: true,
banner: '/** kernel.js by AceMood@Saber-Team */',
compress: {
"sequences" : true, // join consecutive statemets with the “comma operator”
"properties" : true, // optimize property access: a["foo"] → a.foo
"dead_code" : true, // discard unreachable code
"drop_debugger" : true, // discard “debugger” statements
"unsafe" : false, // some unsafe optimizations (see below)
"conditionals" : true, // optimize if-s and conditional expressions
"comparisons" : true, // optimize comparisons
"evaluate" : true, // evaluate constant expressions
"booleans" : true, // optimize boolean expressions
"loops" : true, // optimize loops
"unused" : true, // drop unused variables/functions
"hoist_funs" : true, // hoist function declarations
"hoist_vars" : false, // hoist variable declarations
"if_return" : true, // optimize if-s followed by return/continue
"join_vars" : true, // join var declarations
"cascade" : true, // try to cascade `right` into `left` in sequences
"side_effects" : true, // drop side-effect-free statements
"warnings" : true, // warn about potentially dangerous optimizations/code
"global_defs" : { // global definitions
"DEBUG" : false
}
}
},
pro: {
files: {
'dist/kernel.min.js': ['dist/kernel.src.js']
},
options: {
sourceMapName: 'dist/kernel.min.map'
}
}
},
copy: {
dev: {
src: 'dist/kernel.debug.js',
dest: 'tests/impl/kerneljs/',
filter: 'isFile',
flatten: true,
nonull: true,
expand: true
},
pro: {
src: 'dist/kernel.src.js',
dest: 'tests/impl/kerneljs/',
filter: 'isFile',
flatten: true,
nonull: true,
expand: true
}
}
});
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
// default task
grunt.registerTask('default', [
'clean',
'jshint',
'concat',
'uglify',
'copy'
]);
};