-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
126 lines (122 loc) · 3.55 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
module.exports = function(grunt) {
var date = (function(){
var _date = new Date(),
year = _date.getFullYear(),
month = _date.getMonth()+1,
day = _date.getDate();
return year+'/'+month+'/'+day;
})();
grunt.initConfig({
pkg : grunt.file.readJSON('package.json'),
transport: {
dialog: {
options : {
paths : ['public/src'],
alias : {
'b' : 'test/lottery'
}
},
files : [
{
expand: true,
cwd: 'public/src/',
src : '**/*.js',
dest : '.build',
filter : function(file){
//console.log(grunt.file.isDir(file));
return file.indexOf('node_modules')<0;
}
}
]
}
},
concat: {
dist: {
options : {
paths : ['.build'],
include : 'relative'
},
files : [
{
expand: true,
cwd: '.build/',
src : '**/*.js',
dest : 'public/js'
}
]
},
nojs : {
options : {
noncmd : true
},
files : {
'public/js/nojs/noJS.js' : ['public/src/nojs/noJS.js','public/src/conf.js'],
'public/js/conf.js' : ['public/src/conf.js']
}
},
global : {
options : {
noncmd : true
},
files : {
'public/js/nojs/jquery.js' : ['public/src/nojs/jquery.js','public/src/nojs/ui.js'],
'public/js/m/zepto.js' : ['.build/m/zepto.js','.build/m/ui.js']
}
}
},
clean : {
build : ['.build','public/js/**/*-debug.js'] //清除
},
uglify : {
options: {
banner: '/*'+date+'-<%= pkg.docs %>*/',
mangle: {
except: ['require']
}
},
main : {
files : [
{
expand : true,
cwd: 'public/js/',
src : "**/*.js",
dest : 'public/js/',
ext: ''
}
]
},
min : {
files : [
{
expand : true,
cwd: 'public/src/',
src : "**/*.js",
dest : 'public/min/',
ext: ''
}
]
}
},
watch: {
js : {
files: ['public/src/**/*.js'],
tasks: ['transport','concat','clean','uglify:main'],
options: {
livereload: 1337,
}
}
},
jshint : {
js : ['src/conf.js']
}
});
grunt.loadNpmTasks('grunt-cmd-transport');
grunt.loadNpmTasks('grunt-cmd-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.registerTask('default',['transport','concat','clean']);
grunt.registerTask('min',['uglify:min']);
grunt.registerTask('check',['jshint']);
};