-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathGruntfile.js
108 lines (97 loc) · 2.59 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
var grunt = require('grunt');
// load plugins just in time to speed up grunt
require('jit-grunt')(grunt, {
express: 'grunt-express-server'
});
// report on time taken for each task
require('time-grunt')(grunt);
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'), // read and parse package.json into pkg variable
jshint: { // runs jshint on all js files
all: {
src: ['Gruntfile.js','public/js/*.js'],
options: {
force: false
}
}
},
clean: ['dist'], // deletes everything in this folder
copy: {
html: { // copies html into dist folder
src: ['public/**/*.html'],
dest: 'dist/',
expand: true,
flatten: true
},
photos: { // copies photos into dist/photos
src: ['public/photos/**'],
dest: 'dist/photos/',
flatten: true,
expand: true,
filter: 'isFile'
}
},
less: { // interprets less imports, compiles less > css, concats css into one big file
all: {
files: {
'dist/css/style.css':'public/less/style.less'
}
},
options: {
strictImport: true,
sourceMap: true // allows us to see the less, instead of just the css, in the browser
}
},
uglify: { // combines and ugilifies (minifies) js
all: {
files: {
'dist/js/app.js': ['public/js/*.js'],
'dist/js/tas.js': ['public/js/takeAStand/*.js'],
'dist/js/vendor.js':['public/js/vendor/*.js']
},
},
options: { // switch these flags to turn on minification
compress: false,
mangle: false,
beautify: true
}
},
watch: { // reruns tasks when certain files change
js: {
files: ['public/js/**/*.js'],
tasks: ['uglify']
},
server: {
files: ['server.js'],
tasks: ['default']
},
css: {
files: ['public/less/**/*.less'],
tasks: ['less']
},
html: {
files: ['public/**/*.html'],
tasks: ['copy']
},
grunt: {
files: 'Gruntfile.js',
tasks: ['default']
},
options: {
spawn: false // prevents annoying "EADDRINUSE" exception from express/watch combination
}
},
express: { // starts the server
dev:{
options: {
script: 'server.js',
node_env: 'development'
}
}
}
});
// runs the following tasks when you just type "grunt"
grunt.registerTask('default', ['jshint', 'build']);
// runs the following tasks when you type "grunt build", also referenced in above task
grunt.registerTask('build', ['clean','copy','less', 'uglify', 'express:dev','watch']);
grunt.registerTask('build:only', ['clean', 'copy', 'less', 'uglify']);