-
Notifications
You must be signed in to change notification settings - Fork 5
/
Gruntfile.js
111 lines (107 loc) · 2.51 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
module.exports = function(grunt) {
var target = "development";
if (grunt.option('staging')) target="staging";
if (grunt.option('production') || grunt.option('prod')) target="production";
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-css-url-embed');
if (target == "production") {
var tasks = ['copy', 'browserify', 'uglify', 'less', 'cssUrlEmbed']
} else {
var tasks = ['copy', 'browserify', 'less', 'cssUrlEmbed']
}
grunt.registerTask('build', tasks);
grunt.initConfig({
browserify: {
all: {
options: {
browserifyOptions: {
extensions: ['.jsx', '.js'],
transform: ['babelify', ['aliasify', {
aliases: {
"config": "./src/js/config/"+target+".js"
}
}]]
}
},
files: [{
expand: true,
cwd: 'src',
src: ['js/guest.js'],
dest: './build'
}]
}
},
less: {
all: {
files: {
"build/css/guest.css": "src/less/*.css.less"
}
}
},
cssUrlEmbed: {
encodeDirectly: {
files: {
'build/css/guest.css': ['build/css/guest.css']
}
}
},
uglify: {
options: {
sourceMap: true,
sourceMapIncludeSources: true
},
all: {
files: {
"build/js/guest.js": "build/js/guest.js"
}
}
},
watch: {
js: {
files: ['src/**/*.jsx', 'src/**/*.js'],
tasks: ['browserify']
},
less: {
files: ['src/less/*'],
tasks: ['less']
},
html: {
files: ['src/html/*', 'src/sounds/*'],
tasks: ['copy']
},
images: {
files: ['src/images/*'],
tasks: ['copy', 'less', 'cssUrlEmbed']
}
},
copy: {
html: {
expand: true,
flatten: false,
cwd: 'src/html',
src: ['*'],
dest: 'build/'
},
images: {
expand: true,
flatten: false,
cwd: 'src/images',
src: ['**/*'],
dest: 'build/images/'
},
sounds: {
expand: true,
flatten: false,
cwd: 'src/sounds',
src: ['**/*'],
dest: 'build/sounds/'
}
}
});
// Default task(s).
grunt.registerTask('default', ['browserify']);
};