-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
322 lines (274 loc) · 7.05 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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
module.exports = function (grunt) {
'use strict';
/*
Javascript settings - Edit this section
========================================================================== */
/**
* Specify which js files you want to include
*/
var jsFileList = [
'js/helpers/helpers.js',
'js/helpers/console.js',
'js/script.js'
];
/**
* Specify your output directory
*/
var distDir = 'js/dist/';
/**
* Specify the name of your compiled JS file
* which will be placed in the directory you define above
*/
var jsFile = 'app.min.js';
/* ==================== */
/**
* Project configuration
*/
grunt.initConfig({
pkg: require('./package'),
site: grunt.file.readYAML('src/data/site.yml'),
/**
* JSHint
* https://github.com/gruntjs/grunt-contrib-jshint
* Manage the options inside .jshintrc file
*/
jshint: {
all: jsFileList,
options: {
jshintrc: '.jshintrc'
}
},
/**
* Sass compilation
* https://github.com/gruntjs/grunt-contrib-sass
* Separate options for dev and production environments
* Includes kickoff.scss and kickoff-old-ie.scss by default
* Also creates source maps
*/
sass: {
dev: {
options: {
unixNewlines: true,
style: 'expanded',
lineNumbers: false,
debugInfo : false,
precision : 8,
sourcemap : true
},
files: {
'css/kickoff.css': 'scss/kickoff.scss',
'css/kickoff-old-ie.css': 'scss/kickoff-old-ie.scss'
}
},
production: {
options: {
style: 'compressed',
precision : 8
},
files: {
'css/kickoff.css': 'scss/kickoff.scss',
'css/kickoff-old-ie.css': 'scss/kickoff-old-ie.scss'
}
}
},
/**
* Uglify
* https://github.com/gruntjs/grunt-contrib-uglify
* Minifies and concatinates your JS
* Also creates source maps
*/
uglify: {
options: {
// mangle: Turn on or off mangling
mangle: true,
// beautify: beautify your code for debugging/troubleshooting purposes
beautify: false,
// report: Show file size report
report: 'gzip',
// sourceMap: @string. The location of the source map, relative to the project
sourceMap: jsFile + '.map',
// sourceMappingURL: @string. The string that is printed to the final file
sourceMappingURL: '../../'+ jsFile +'.map'
// sourceMapRoot: @string. The location where your source files can be found. This sets the sourceRoot field in the source map.
// sourceMapRoot: 'js',
// sourceMapPrefix: @integer. The number of directories to drop from the path prefix when declaring files in the source map.
// sourceMapPrefix: 1,
},
/**
* Use the array at the top of this file to specify which js files you include
*/
js: {
src: jsFileList,
dest: distDir + jsFile
}
},
/**
* Watch
* https://github.com/gruntjs/grunt-contrib-watch
* Watches your scss, js etc for changes and compiles them
*/
watch: {
scss: {
files: ['scss/**/*.scss'],
tasks: ['sass:dev', 'copy:css']
// tasks: ['sass:dev', 'autoprefixer:dist', 'csso']
},
js: {
files: [
'Gruntfile.js',
'js/*.js',
'js/libs/**/*.js'
],
tasks: ['uglify', 'copy:js']
},
assemble : {
files: ['src/templates/**/*.hbs'],
tasks: ['assemble']
},
livereload: {
options: { livereload: true },
files: [
'dist/*.html',
'css/*.css'
]
}
},
connect: {
options: {
port: 9000,
// change this to '0.0.0.0' to access the server from outside
hostname: 'tvw.local'
},
server: {
options: {
base: 'dist'
}
}
},
open: {
server: {
path: 'http://localhost:<%= connect.options.port %>'
}
},
/**
* Autoprefixer
* https://github.com/ai/autoprefixer
* Auto prefixes your CSS using caniuse data
*/
autoprefixer: {
dist : {
options: {
// Task-specific options go here - we are supporting
// the last 2 browsers, any browsers with >1% market share,
// and ensuring we support IE7 + 8 with prefixes
browsers: ['last 2 versions', '> 1%', 'ie 8', 'ie 7']
},
files: {
'css/kickoff.prefixed.css': 'css/kickoff.css',
'css/kickoff-old-ie.prefixed.css': 'css/kickoff-old-ie.css'
}
}
},
/**
* CSSO
* https://github.com/t32k/grunt-csso
* Minify CSS files with CSSO
*/
csso: {
dist: {
files: {
'css/kickoff.min.css': ['css/kickoff.prefixed.css'],
'css/kickoff-old-ie.min.css': ['css/kickoff-old-ie.prefixed.css']
},
}
},
assemble: {
options: {
data: 'src/**/*.{json,yml}',
assets: '<%= site.destination %>/assets',
helpers: 'src/helpers/helper-*.js',
layoutdir: 'src/templates/layouts',
partials: ['src/templates/includes/**/*.hbs'],
flatten: true
},
site: {
// Target-level options
options: {layout: 'default.hbs'},
files: [
{ expand: true, cwd: 'src/templates/pages', src: ['*.hbs'], dest: '<%= site.destination %>/' }
]
}
},
copy: {
dist: {
files: [
{ expand: true, cwd: './css', src: ['./**/*.*'], dest: 'dist/assets/css' },
{ expand: true, cwd: './js', src: ['./**/*.*'], dest: 'dist/assets/js' }
]
},
css: {
files: [
{ expand: true, cwd: './css', src: ['./**/*.*'], dest: 'dist/assets/css' }
]
},
js: {
files: [
{ expand: true, cwd: './js', src: ['./**/*.*'], dest: 'dist/assets/js' }
]
}
},
readme: {
options: {
sep: '',
docs: ['docs/']
}
}
});
// Load some stuff
grunt.loadNpmTasks('grunt-readme');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-open');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-autoprefixer');
grunt.loadNpmTasks('grunt-csso');
grunt.loadNpmTasks('assemble');
grunt.loadNpmTasks('grunt-newer');
grunt.loadNpmTasks('grunt-contrib-copy');
/**
* Available tasks:
* grunt : run jshint, uglify and sass:dev
* grunt watch : run sass:dev, uglify and livereload
* grunt dev : run jshint, uglify and sass:dev
* grunt deploy : run jshint, uglify and sass:production
*/
/**
* Default task
* run jshint, uglify and sass:dev
*/
// Default task
grunt.registerTask('default', ['readme', 'jshint', 'uglify', 'sass:dev', 'newer:assemble', 'copy:dist']);
grunt.registerTask('server', function (target) {
grunt.task.run([
'connect',
'open',
'watch'
]);
});
/*
NEED TO UPDATE DEV AND PROD GRUNT BUILDS AS THESE ARE JUST PLACEHOLDERS
*/
/**
* A task for development
* run jshint, uglify and sass:dev
*/
grunt.registerTask('dev', ['jshint', 'uglify', 'sass:dev']);
/**
* A task for your production environment
* run jshint, uglify and sass:production
*/
grunt.registerTask('deploy', ['jshint', 'uglify', 'sass:production']);
// grunt.registerTask('production', ['jshint', 'uglify', 'sass:production', 'autoprefixer', 'csso']);
};