-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathGruntfile.js
118 lines (107 loc) · 2.41 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
'use strict';
var path = require('path');
module.exports = function(grunt){
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
var settings = require('./lib/settings');
grunt.initConfig({
clean: {
dist: 'dist/*'
},
jshint: {
options: {
jshintrc: '.jshintrc'
},
dist: [
'app/js/**/*.js'
]
},
useminPrepare: {
html: 'app/individual.html',
options: {
dest: 'dist',
flow: {
steps: {
js: ['uglifyjs'],
css: ['concat', 'cssmin']
},
post: {}
}
}
},
usemin: {
html: ['dist/*.html'],
css: ['dist/css/**/*.css'],
options: {
dirs: ['dist']
}
},
uglify: {
options: {
sourceMap: function(name) {
return name + '.map';
},
sourceMappingURL: function(name) {
return '/js/' + path.basename(name) + '.map';
}
}
},
copy: {
dist: {
files: [{
expand: true,
dot: true,
cwd: 'app',
dest: 'dist',
src: [
'*.{ico,txt,html}',
'images/**/*',
'css/fonts/**/*'
]
}]
}
},
open: {
dist: {
path: 'http://localhost:' + settings.port
}
}
});
grunt.registerTask('launchServer', 'Launch the local proxy server', function(env) {
var args = [];
if (env === 'dev') args.push ('--dev');
var serverHandle = require('child_process').fork('./app', args);
// Open the page in your browser.
grunt.task.run('open', 'holdAfterLaunch');
// Cleanup
process.on('exit', function() {
serverHandle.kill();
});
});
grunt.registerTask('holdAfterLaunch', function() {
// Run in async mode so this never completes.
this.async();
console.log('\nRunning local proxy server on port ' + settings.port + '. Press CTRL-C to exit.\n');
});
grunt.registerTask('test', [
// TODO
]);
grunt.registerTask('develop', [
// watch task will go here soon
'launchServer:dev'
]);
grunt.registerTask('build', [
'clean:dist',
'useminPrepare',
'concat',
'cssmin',
'uglify',
'copy',
'usemin'
]);
grunt.registerTask('default', [
//'jshint', // re-enable this when the code gets a little more sane
'test',
'build',
'launchServer:prod'
]);
};