-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGruntfile.js
141 lines (122 loc) · 3.76 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*
Usage
--------------
# run build tasks is build_state (default dev)
# start watching for changes and build on changes
grunt
# build with compressed css and js
# does NOT start watch
grunt prod
Project Setup
--------------
# install grunt for this project (generates ./node_modules)
# run from within this directory
npm install
# NOTE: Machine Setup (heading below) must have occurred
# at least once previously on this machine
Machine Setup
--------------
# install nodejs from
http://nodejs.org/download/
# from the command line install grunt cli
sudo npm install -g grunt-cli
# from the commdand line install sass
sudo gem install sass
*/
// we can set our default build state to either
// 'prod' or 'dev'
// this value will be used for both the
// initial process when `grunt` alone is run
// as well as the tasks run via watch
var build_state = 'dev',
// sass src files are loaded with sass includes
// no need to list them here (i.e. only one sass src)
sass_files = {
"assets/css/toggle-psd.min.css": "assets/css/sass/toggle-psd.scss"
},
// watch all .scss files in our sass directory
// for changes
watched_sass_files = [ 'assets/css/sass/**/*.scss' ],
uglify_files = {
'assets/js/toggle-psd.min.js': [
'assets/js/setup.js',
'assets/js/models/*.js',
'assets/js/views/*.js',
'assets/js/collections/*.js',
'assets/js/ready.js',
]
},
watched_js_files = [
'assets/js/setup.js',
'assets/js/models/*.js',
'assets/js/views/*.js',
'assets/js/collections/*.js',
'assets/js/ready.js',
];
module.exports = function(grunt) {
"use strict";
grunt.initConfig({
// `grunt watch`
watch: {
sass: {
files: watched_sass_files,
tasks: ["sass:"+build_state],
options: {
livereload: true
}
},
js: {
files: watched_js_files,
tasks: ["uglify:"+build_state],
options: {
livereload: true
}
}
}, // watch
uglify: {
// `grunt uglify:dev`
dev: {
files: uglify_files,
options: {
beautify: true,
mangle: false,
sourceMap: true
},
},
// `grunt uglify:prod`
prod: {
files: uglify_files,
options: {
compress: {
drop_console: true
}
}
}
}, // uglify
sass: {
// `grunt sass:dev`
dev: {
options: { outputStyle: "nested" },
files: sass_files,
},
// `grunt sass:prod`
prod: {
options: { outputStyle: "compressed" },
files: sass_files,
}
} // sass
});
// when `grunt` is run, do the following tasks
// run all tasks associated with build_state
// (either prod or dev), start watch
// (note: watch also uses build_state when generating output)
grunt.registerTask('default', [build_state, 'watch']);
// when `grunt prod` is run, do the following tasks
grunt.registerTask('prod', ['sass:prod', 'uglify:prod']);
// when `grunt dev` is run, do the following tasks
grunt.registerTask('dev', ['sass:dev', 'uglify:dev']);
// load these tasks (necessary to allow use of sass, watch, and uglify
grunt.loadNpmTasks("grunt-sass");
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-contrib-uglify");
};