-
Notifications
You must be signed in to change notification settings - Fork 4
/
Gruntfile.js
121 lines (116 loc) · 3.88 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
module.exports = function(grunt) {
// load tasks
[ 'grunt-contrib-uglify',
'grunt-contrib-cssmin',
'grunt-contrib-jshint',
'grunt-contrib-concat',
'grunt-contrib-watch'
].forEach(function(task) {
grunt.loadNpmTasks(task);
});
var files = {
gruntfile: ['Gruntfile.js'],
frontjs: ['public/src/js/spec.js', 'public/src/js/manager/*.js'], //to be compressed
backjs: ['specapp.js','routes/**/*.js', 'modules/**/*.js'],
};
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
stuff: {
files: {
'public/dist/js/db.js': ['public/src/js/db/*.js'],
'public/dist/js/plugins.js': ['public/src/js/plugins/*.js'],
},
options: {
// Replace all 'use strict' statements in the code with a single one at the top
// banner: "'use strict';\n",
process: function(src, filepath) {
return '// Source: ' + filepath + '\n' +
src.replace(/(^|\n)[ \t]*('use strict'|"use strict");?\s*/g, '$1');
},
},
}
},
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= pkg.version %> */\n',
mangle: {
except: ['Spec']
}
},
dist: {
files: {
'public/dist/js/spec.min.js': ['public/src/js/spec.js'],
'public/dist/js/db.min.js': ['public/dist/js/db.js'],
'public/dist/js/plugins.min.js': ['public/dist/js/plugins.js']
}
},
managerPages: {
files: [{
expand: true,
cwd: 'public/src/js/manager',
src: '**/*.js',
dest: 'public/dist/js/manager',
ext: '.min.js'
}]
}
},
jshint: {
//Front end files
//no need to lint plugins
files: [].concat(files.frontjs, files.gruntfile),
ignore_warning: {
options: {
'-W030': true,
'-W002': true
},
src: files.backjs, //Back end files
},
options: {
// options here to override JSHint defaults
globals: {
jQuery: true,
console: true,
module: true,
document: true
}
}
},
cssmin: {
options: {
banner: '/*! <%= pkg.name %> <%= pkg.version %> */\n'
},
combine: {
files: {
'public/dist/css/db.min.css': ['public/src/css/db/*.css'],
'public/dist/css/manager.min.css': ['public/src/css/manager/*.css'],
'public/dist/css/plugins.min.css': ['public/src/css/plugins/*.css'],
}
},
minify: {
expand: true,
cwd: 'public/src/css/',
src: ['*.css', '!*.min.css'],
dest: 'public/dist/css/',
ext: '.min.css'
}
},
watch: {
frontjs: {
files: files.frontjs,
tasks: ['buildjs']
},
otherjs: {
files: [].concat(files.backjs, files.gruntfile),
tasks: ['jshint']
},
css: {
files: 'public/src/css/*',
tasks: ['buildcss']
}
}
});
grunt.registerTask('buildjs', ['jshint', 'concat', 'uglify']);
grunt.registerTask('buildcss', ['cssmin']);
grunt.registerTask('default', ['buildjs', 'buildcss']);
};