-
Notifications
You must be signed in to change notification settings - Fork 4
/
Gruntfile.js
101 lines (96 loc) · 2.24 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
module.exports = function(grunt) {
//grunt plugins
require('load-grunt-tasks')(grunt);
//Project configuration
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
watch: {
development: {
files: ['app.js', 'app/**/*.js'],
tasks: ['develop:development'],
options: { nospawn: false }
},
production: {
files: ['app.js', 'app/**/*.js'],
tasks: ['develop:production'],
options: { nospawn: false }
}
},
develop: {
//Auto restart application
development: {
file: 'app.js',
env: { NODE_ENV: 'development' }
},
production: {
file: 'app.js',
env: { NODE_ENV: 'production' }
}
},
copy: {
main: {
expand: true,
cwd: 'asset/dev',
src: '**',
dest: 'asset/dest'
}
},
cssmin: {
compile: {
expand: true,
cwd: 'asset/dev',
src: ['**/*.css', '**/!*.min.css'],
dest: 'asset/dest'
}
},
requirejs: {
compile: {
options: {
baseUrl: "asset/dev/js",
dir: "asset/dest/js",
modules: [
{
name: 'main'
}
],
shim: {
jquery: {
exports: '$'
},
underscore: {
exports: '_'
}
},
paths: {
jquery: '../lib/jquery',
underscore: '../lib/underscore',
backbone: '../lib/backbone',
text: '../lib/text',
markdown: '../lib/markdown'
}
}
}
}
});
//All tasks
grunt.registerTask('build', ['copy', 'cssmin', 'requirejs']);
grunt.registerTask('app', function(env) {
var spawn = require('child_process').spawn;
env = env || 'development';
//Start app
var start = spawn('node', ['app.js'], {
env: env
});
start.stdout.on('data', function (data) {
console.log('stdout: ' + data);
});
start.stderr.on('data', function (data) {
console.log('stderr: ' + data);
});
if (env == 'development') {
grunt.task.run(['watch:development']);
} else {
grunt.task.run(['watch:production']);
}
});
}