-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGruntfile.js
65 lines (63 loc) · 1.5 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
module.exports = function(grunt) {
grunt.initConfig({
update: {
file: '../config.js',
template: '../config.tpl',
format: 'yyyy-mmdd-HHMM'
},
transport: {
app: {
options: {
paths: ['app'],
idleading: '/app/'
},
files: [{
expand: true,
cwd: 'app',
src: '**/*.js',
dest: '.build'
}]
}
},
concat: {
app: {
src: ['.build/**/*.js'],
filter: function(path) {
if (/^.*[\/\\].+-debug\.js/.test(path)) {
return false;
}
return true;
},
dest: ".build/app.pack.js"
}
},
uglify: {
app: {
src: '.build/app.pack.js',
dest: 'dist/app.pack.min.js'
},
cocos: {
src: 'lib/cocos2d-js-v3.3.js',
dest: 'lib/cocos2d-js-v3.3.min.js'
}
},
clean: {
build: ['.build']
}
});
grunt.loadNpmTasks('grunt-cmd-transport');
//合并CMD模块使用 grunt-cmd-concat
grunt.loadNpmTasks('grunt-cmd-concat');
//普通文件合并使用 grunt-contrib-concat
//grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.registerTask('default', ['transport:app', 'concat:app', 'uglify:app', 'clean']);
grunt.registerTask('update', 'update version file', function() {
var template = grunt.file.read(grunt.config('update.template'));
data = {
version: grunt.template.today(grunt.config('update.format'))
};
grunt.file.write(grunt.config('update.file'), grunt.template.process(template, {data:data}));
});
};