-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
191 lines (164 loc) · 4.93 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
module.exports = function( grunt ) {
'use strict';
//
// Grunt configuration:
//
// https://github.com/cowboy/grunt/blob/master/docs/getting_started.md
//
grunt.loadNpmTasks('grunt-recess');
grunt.initConfig({
// Project configuration
// ---------------------
// LESS compilation
recess: {
dist: {
src: 'app/styles/main.less',
dest: 'temp/styles/main.css',
options: {
compile: true
}
}
},
// generate application cache manifest
manifest:{
dest: ''
},
// headless testing through PhantomJS
mocha: {
all: ['test/**/*.html']
},
// default watch configuration
watch: {
recess: {
files: 'app/styles/**/*.less',
tasks: 'recess reload'
},
reload: {
files: [
'app/*.html',
'app/styles/**/*.css',
'app/scripts/**/*.js',
'app/images/**/*'
],
tasks: 'reload'
}
},
// default lint configuration, change this to match your setup:
// https://github.com/cowboy/grunt/blob/master/docs/task_lint.md#lint-built-in-task
lint: {
options: {
// specifying JSHint options and globals
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
boss: true,
eqnull: true,
browser: true,
node: true
},
globals: {
jQuery: true,
require: true,
define: true
}
},
files: [
'Gruntfile.js',
'app/scripts/**/*.js',
'spec/**/*.js'
]
},
// Build configuration
// -------------------
// the staging directory used during the process
staging: 'temp',
// final build output
output: 'dist',
mkdirs: {
staging: 'app/'
},
server: {
app: 'clean recess watch'
},
// Below, all paths are relative to the staging directory, which is a copy
// of the app/ directory. Any .gitignore, .ignore and .buildignore file
// that might appear in the app/ tree are used to ignore these values
// during the copy process.
// concat css/**/*.css files, inline @import, output a single minified css
css: {
'styles/main.css': ['styles/**/*.css']
},
// renames JS/CSS to prepend a hash of their contents for easier
// versioning
rev: {
js: 'scripts/**/*.js',
css: 'styles/**/*.css',
img: ''
},
// usemin handler should point to the file containing
// the usemin blocks to be parsed
'usemin-handler': {
html: 'index.html'
},
// update references in HTML/CSS to revved files
usemin: {
html: ['index.html'],
css: ['styles/**/*.css']
},
// HTML minification
html: {
files: ['**/*.html']
},
// Optimizes JPGs and PNGs (with jpegtran & optipng)
img: {
dist: 'images/**'
},
// rjs configuration. You don't necessarily need to specify the typical
// `path` configuration, the rjs task will parse these values from your
// main module, using http://requirejs.org/docs/optimization.html#mainConfigFile
//
// name / out / mainConfig file should be used. You can let it blank if
// you're using usemin-handler to parse rjs config from markup (default
// setup)
rjs: {
// no minification, is done by the min task
optimize: 'none',
baseUrl: 'app/scripts',
wrap: true,
name: 'main'
},
// While Yeoman handles concat/min when using
// usemin blocks, you can still use them manually
concat: {
dist: ''
},
min: {
dist: ''
}
});
// usemin:post:* are the global replace handlers, they delegate the regexp
// replace to the replace helper.
grunt.registerHelper('usemin:post:html', function(content) {
grunt.log.verbose.writeln('Update the HTML to reference our concat/min/revved script files');
content = grunt.helper('replace', content, /<script.+src=['"](.+)["'][\/>]?><[\\]?\/script>/gm);
grunt.log.verbose.writeln('Update the HTML with the new css filenames');
content = grunt.helper('replace', content, /<link[^\>]+href=['"]([^"']+)["']/gm);
grunt.log.verbose.writeln('Update the HTML with anchors images');
content = grunt.helper('replace', content, /<a[^\>]+href=['"]([^"']+)["']/gm);
return content;
});
grunt.registerHelper('usemin:post:css', function(content) {
return content;
});
// Alias the `test` task to run the `mocha` task instead
grunt.registerTask('test', 'lint mocha');
grunt.registerTask('test-server', 'grunt-server');
grunt.registerTask('build', 'intro clean recess mkdirs usemin-handler concat css min img rev usemin copy time');
grunt.registerTask('build:minify', 'intro clean recess mkdirs usemin-handler concat css min img rev usemin html:compress copy time');
};