-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
118 lines (111 loc) · 3.33 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
(function() {
'use strict';
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
options: {
newcap: false
},
all: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js']
},
cafemocha: {
all: {
src: 'test/**/*.js',
options: {
ui: 'bdd',
reporter: 'list'
}
}
},
browserify: {
'build/brot.js': 'src/brot.js'
},
watch: {
dev: {
files: ['src/**/*.js', '!src/textbrot.js', 'test/**/*.js'],
tasks: ['usetheforce_on', 'test', 'build', 'usetheforce_off'],
options: {
livereload: true
}
},
test: {
files: ['src/**/*.js', 'test/**/*.js', 'Gruntfile.js'],
tasks: ['usetheforce_on', 'test', 'usetheforce_off']
}
},
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: {
options: {
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> */\n'
},
nomin: {
options: {
mangle: false,
compress: false,
beautify: true
},
files: {
'build/brot.js': ['build/brot.js']
}
},
min: {
files: {
'build/brot.min.js': ['build/brot.js']
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-cafe-mocha');
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', 'test', 'build',
'connect', 'open', 'watch:dev', 'usetheforce_off']);
grunt.registerTask('test', 'Lint and test source files',
['jshint', 'cafemocha']);
grunt.registerTask('watchtest', 'Watch for changes and lint and test source files',
['usetheforce_on', 'test', 'watch:test', 'usetheforce_off']);
grunt.registerTask('build', 'Combine and compress source for the frontend',
['browserify', 'uglify']);
grunt.registerTask('default', ['develop']);
};
})();