forked from pboyer/flood
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
executable file
·263 lines (243 loc) · 7.9 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
'use strict';
var lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet;
var mountFolder = function (connect, dir) {
return connect.static(require('path').resolve(dir));
};
// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to match all subfolders:
// 'test/spec/**/*.js'
// templateFramework: 'lodash'
module.exports = function (grunt) {
// load all grunt tasks
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
// configurable paths
var yeomanConfig = {
app: 'app',
dist: 'dist'
};
grunt.initConfig({
yeoman: yeomanConfig,
watch: {
livereload: {
files: [
'<%= yeoman.app %>/*.html',
'{.tmp,<%= yeoman.app %>}/styles/{,*/}*.css',
'{.tmp,<%= yeoman.app %>}/scripts/{,*/}*.js',
'<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp}'
],
tasks: ['livereload']
}
},
connect: {
options: {
port: 9000,
// change this to '0.0.0.0' to access the server from outside
hostname: 'localhost'
},
livereload: {
options: {
middleware: function (connect) {
return [
lrSnippet,
mountFolder(connect, '.tmp'),
mountFolder(connect, 'app')
];
}
}
},
test: {
options: {
middleware: function (connect) {
return [
mountFolder(connect, '.tmp'),
mountFolder(connect, 'test')
];
}
}
},
dist: {
options: {
middleware: function (connect) {
return [
mountFolder(connect, 'dist')
];
}
}
}
},
open: {
server: {
path: 'http://localhost:<%= connect.options.port %>'
}
},
clean: {
dist: ['.tmp', '<%= yeoman.dist %>/*'],
server: '.tmp'
},
mocha: {
all: {
options: {
run: true,
urls: ['http://localhost:<%= connect.options.port %>/index.html']
}
}
},
// This task uses James Burke's excellent r.js AMD builder to take all
// modules and concatenate them into a single file.
requirejs: {
release: {
options: {
mainConfigFile: "app/scripts/config.js",
// generateSourceMaps: true,
include: ["main"],
insertRequire: ["main"],
out: "dist/source.min.js",
optimize: "uglify",
// optimize: "none",
// Since we bootstrap with nested `require` calls this option allows
// R.js to find them.
findNestedDependencies: true,
// Include a minimal AMD implementation shim.
name: "almond",
// Setting the base url to the distribution directory allows the
// Uglify minification process to correctly map paths for Source
// Maps.
baseUrl: "app/scripts",
// Wrap everything in an IIFE.
wrap: true,
// Do not preserve any license comments when working with source
// maps. These options are incompatible.
preserveLicenseComments: false
}
}
},
imagemin: {
dist: {
files: [{
expand: true,
cwd: '<%= yeoman.app %>/images',
src: '{,*/}*.{png,jpg,jpeg}',
dest: '<%= yeoman.dist %>/images'
}]
},
jqueryui: {
files: [{
expand: true,
flatten: true,
cwd: '<%= yeoman.app %>',
src: 'bower_components/jquery.ui/themes/base/images/*.png',
dest: '<%= yeoman.dist %>/images'
}]
}
},
cssmin: {
dist: {
files: {
'<%= yeoman.dist %>/style.min.css': [
'.tmp/styles/{,*/}*.css',
'<%= yeoman.app %>/bower_components/jquery.ui/themes/base/*.css',
'<%= yeoman.app %>/bower_components/components-font-awesome/css/font-awesome.min.css',
'<%= yeoman.app %>/styles/{,*/}*.css',
]
}
}
},
copy: {
dist: {
files: [{
expand: true,
dot: true,
cwd: '<%= yeoman.app %>',
dest: '<%= yeoman.dist %>',
src: [
'*.{ico,txt}',
'.htaccess',
'*.html',
'*.json',
'images/{,*/}*.{webp,gif,png}',
'bower_components/jquery/jquery.js',
'bower_components/components-font-awesome/css/font-awesome.min.css',
'bower_components/components-font-awesome/fonts/*.{ttf,eot,svg,woff,otf}',
'scripts/lib/flood/*.js'
]
}]
},
fonts: {
files: [{
expand: true,
dot: true,
flatten: true,
cwd: '<%= yeoman.app %>',
dest: '<%= yeoman.dist %>/fonts',
src: [
'bower_components/components-font-awesome/fonts/*.{ttf,eot,svg,woff,otf}'
]
}]
}
},
bower: {
all: {
rjsConfig: '<%= yeoman.app %>/scripts/main.js'
}
},
processhtml: {
release: {
files: {
"dist/app.html": ["app/app.html"]
}
}
},
nodewebkit: {
options: {
version: '0.8.1',
build_dir: './dist_desktop', // Where the build version of my node-webkit app is saved
mac: true, // We want to build it for mac
win: true, // We want to build it for win
linux32: false, // We don't need linux32
linux64: false // We don't need linux64
},
src: ['./dist/**'] // Your node-wekit app
}
});
grunt.renameTask('regarde', 'watch');
grunt.registerTask('server', function (target) {
if (target === 'dist') {
return grunt.task.run(['build', 'open', 'connect:dist:keepalive']);
}
grunt.task.run([
'clean:server',
'livereload-start',
'connect:livereload',
'open',
'watch'
]);
});
grunt.registerTask('test', [
'clean:server',
'connect:test',
'mocha'
]);
grunt.registerTask('build', [
'clean:dist',
'requirejs',
'imagemin',
'cssmin',
'copy',
'processhtml'
]);
grunt.registerTask('desktop', [
'clean:dist',
'requirejs',
'imagemin',
'cssmin',
'copy',
'processhtml',
'nodewebkit'
]);
grunt.registerTask('default', [
'test',
'build'
]);
};