-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
127 lines (117 loc) · 3.36 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
'use strict';
module.exports = function(grunt) {
const clientFile = 'dist/client-1.0.1.js'; // Should match index.html's reference
const intermediateBrowserifyFile = 'dist/tmp-browserified.js'; // Used by Uglify
const browserifyOptions = {
transform: [
['babelify', { presets: 'es2015' } ]
]
};
const bowerOptions = {
srcPrefix: 'bower_components',
destPrefix: 'dist'
};
grunt.initConfig({
browserify: {
dev: {
options: browserifyOptions,
src: ['src/js/main.js'],
dest: clientFile
},
prod: {
options: browserifyOptions,
src: ['src/js/main.js'],
dest: intermediateBrowserifyFile
}
},
bowercopy: {
dev: {
options: bowerOptions,
files: {
'pixi-3.0.8.js': 'pixi.js/bin/pixi.js',
'howler-1.1.28.js': 'howler.js/howler.js'
}
},
prod: {
options: bowerOptions,
files: {
'pixi-3.0.8.js': 'pixi.js/bin/pixi.min.js',
'howler-1.1.28.js': 'howler.js/howler.min.js'
}
}
},
copy: {
index: {
src: 'src/index.html',
dest: 'dist/index.html'
},
media: {
expand: true, // I wonder what this does?
cwd: 'media/assets/',
src: '**/*',
dest: 'dist/assets/'
}
},
watch: {
js: {
files: ['src/js/**/*.js'],
tasks: ['browserify:dev']
},
index: {
files: ['src/index.html'],
tasks: ['copy:index']
},
media: {
files: ['media/assets/*'],
tasks: ['copy:media'] // TODO: This could be modified to copy only the modified file(s)
}
},
connect: {
server: {
options: {
port: 8080,
base: 'dist'
}
}
},
uglify: {
client: {
src: [intermediateBrowserifyFile],
dest: clientFile
}
},
clean: {
all: ['dist'],
'after-uglify': [intermediateBrowserifyFile]
}
});
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-bowercopy');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-clean');
// Standard dev workflow.
grunt.registerTask('default', [
'browserify:dev',
'bowercopy:dev',
'copy',
'connect',
'watch'
]);
// Prepare for production.
grunt.registerTask('finalize', [
'clean:all',
'browserify:prod',
'uglify',
'clean:after-uglify',
'bowercopy:prod',
'copy'
]);
// Start a server quickly without building anything.
grunt.registerTask('server', [
'connect',
'watch'
]);
};