forked from ancon/bigscreen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGruntfile.js
More file actions
78 lines (73 loc) · 1.9 KB
/
Gruntfile.js
File metadata and controls
78 lines (73 loc) · 1.9 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
/*global module:false*/
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
//测试文件
qunit: {
files: ['index.html']
},
//js代码验证
jshint: {
files: ['Gruntfile.js','static/_src/js/*.js'],
options: {
globals: {
jQuery: true,
console: true,
module: true
}
},
},
//合并文件
concat: {
options: {
separator: '\n\n\n\n'
},
concatcss: {
src: 'static/_src/css/*.css',
dest: 'static/css/<%= pkg.name %>.css'
},
concatjs: {
src: 'static/_src/js/*.js',
dest: 'static/js/<%= pkg.name %>.js'
}
},
//压缩JS文件
uglify: {
dist: {
files: {
'static/js/<%= pkg.name %>.min.js':['<%= concat.concatjs.dest %>'],
}
},
options: {
banner: '/*! <%= pkg.name %>\nauthor:<%= pkg.author.name %>\n<%= grunt.template.today("yyyy-mm-dd") %>*/\n',
report: 'min'
}
},
//压缩CSS
cssmin: {
css: {
src: ['<%= concat.concatcss.dest %>'],
dest: 'static/css/<%= pkg.name %>.min.css'
}
},
//侦听
watch: {
files: ['<%= jshint.files %>'],
tasks: ['jshint','qunit']
}
});
// Lib tasks.
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-css');
grunt.loadNpmTasks('grunt-contrib-watch');
//默认任务:命令行输入grunt
defaultTasks = ['concat','uglify','cssmin','qunit','cssmin','watch'];
grunt.registerTask('default', defaultTasks);
//自定义任务,命令行输入 grunt min,合并压缩JS/CSS
minTasks = ['concat','uglify','cssmin'];
grunt.registerTask('min', minTasks);
};