-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathGruntfile.js
118 lines (105 loc) · 2.55 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
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
paths: {
js: {
dest: 'app/public/javascripts',
src: 'app/assets/javascripts',
components: 'app/bower_components',
config: 'app/config',
temp: '.temp/javascripts'
}
},
clean: {
server: ['<%= concat.serverConfig.dest %>'],
client: ['.temp']
},
coffee: {
compile: {
options: {
bare: true
},
dest: '<%= paths.js.temp %>/app.js',
src: ['<%= paths.js.src %>/app.coffee']
}
},
concat: {
vendor: {
options: {stripBanners: true},
dest: '<%= paths.js.dest %>/vendor.js',
src: [
'<%= paths.js.components %>/preloadjs/lib/preloadjs-0.4.1.min.js',
'<%= paths.js.components %>/easeljs/lib/easeljs-0.7.1.min.js',
'<%= paths.js.components %>/jQuery/dist/jquery.min.js',
'<%= paths.js.components %>/underscore/underscore-min.js',
'<%= paths.js.components %>/backbone/backbone-min.js',
]
},
serverConfig: {
options: {
banner: 'module.exports = ',
footer: ';'
},
dest: '<%= paths.js.config %>/server_config.js',
src: '<%= paths.js.config %>/shared.json'
},
clientConfig: {
options: {
banner: '(function(Slots, undefined){\nSlots.config = Slots.config || {};\n_.extend(Slots.config, ',
footer: ');\n})(window.Slots || {});'
},
dest: '<%= paths.js.temp %>/client_config.js',
src: '<%= paths.js.config %>/shared.json'
},
clientApp: {
dest: '<%= paths.js.dest %>/app.js',
src: [
'<%= concat.clientConfig.dest %>',
'<%= coffee.compile.dest %>'
]
}
},
uglify: {
app: {
options: {
sourceMap: 'app.min.map',
sourceMappingURL: 'app.js',
wrap: true
},
dest: '<%= paths.js.dest %>/app.min.js',
src: '<%= concat.clientApp.dest %>',
}
},
watch: {
js: {
files: [
'<%= coffee.compile.src %>',
'<%= paths.js.config %>/shared.json'
],
tasks: ['buildClientJS']
}
}
});
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-coffee');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('build', [
'clean',
'buildClientJS',
'buildVendorJS',
'concat:serverConfig'
]);
grunt.registerTask('buildClientJS', [
'coffee',
'concat:clientConfig',
'concat:clientApp',
'clean:client',
'uglify'
]);
grunt.registerTask('buildVendorJS', [
'concat:vendor'
]);
grunt.registerTask('default', ['build']);
};