-
Notifications
You must be signed in to change notification settings - Fork 31
/
Gruntfile.js
96 lines (89 loc) · 3.15 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
(function() {
'use strict';
module.exports = function(grunt) {
grunt.initConfig({
jshint: {
options: {
newcap: false
},
all: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js']
},
browserify: {
'build/all.js': 'src/main.js'
},
watch: {
dev: {
files: ['src/**/*.js'],
tasks: ['usetheforce_on', 'build', 'usetheforce_off'],
options: {
livereload: true
}
}
},
connect: {
options: {
port: 8008,
hostname: 'localhost',
base: '.'
},
dev: {
options: {
middleware: function(connect, options) {
return [
require('connect-livereload')(),
connect.static(options.base)
];
}
}
}
},
open: {
dev: {
path: 'http://localhost:8008/index.dev.html'
}
},
uglify: {
nomin: {
options: {
mangle: false,
compress: false,
beautify: true
},
files: {
'build/all.js': ['build/all.js']
}
},
min: {
files: {
'build/all.min.js': ['build/all.js']
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-open');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-uglify');
// Workaround to force continuation when encountering errors
// during development cycle (for watch / livereload)
grunt.registerTask('usetheforce_on', '// force the force option', function() {
if (!grunt.option('force')) {
grunt.config.set('usetheforce', true);
grunt.option('force', true);
}
});
grunt.registerTask('usetheforce_off', '// remove the force option', function() {
if (grunt.config.get('usetheforce')) {
grunt.option('force', false);
}
});
grunt.registerTask('develop', 'Setup development server and watch files',
['usetheforce_on', 'build', 'connect', 'open',
'watch:dev', 'usetheforce_off']);
grunt.registerTask('build', 'Combine and compress source for the frontend',
['browserify', 'uglify']);
grunt.registerTask('default', ['develop']);
};
})();