-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
103 lines (95 loc) · 2.1 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
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
require('time-grunt')(grunt);
grunt.initConfig({
browserify: {
dist: {
options: {
transform: [
['babelify', {
presets: ['es2015', 'react']
}]
],
watch: true
},
files: {
'./dist/app.js': ['./src/js/app.js']
}
}
},
less: {
development: {
options: {
compress: true
},
files: {
'./dist/styles.css': './src/less/styles.less',
}
}
},
uglify: {
options: {
mangle: true
},
build: {
files: {
'./dist/app.min.js': ['./dist/app.js']
}
}
},
connect: {
server: {
options: {
port: 1337,
hostname: 'localhost',
livereload: 9000,
middleware: function(connect, options) {
var middlewares = [];
if(!Array.isArray(options.base)) {
options.base = [options.base];
}
middlewares.push(require('grunt-connect-proxy/lib/utils').proxyRequest);
options.base.forEach(function(base) {
middlewares.push(connect.static(base));
});
return middlewares;
}
},
proxies: [{
context: ['/api'],
host: '127.0.0.1',
port: 1338
}]
}
},
watch: {
scripts: {
files: ['./src/js/**/*.js'],
options: {
livereload: {
port: 9000
}
}
},
styles: {
files: ['./src/less/*.less'],
tasks: ['less'],
options: {
livereload: {
port: 9000
}
}
},
watch: {
files: ['*.html'],
options: {
livereload: {
port: 9000
}
}
}
}
});
grunt.registerTask('default', ['less', 'browserify', 'configureProxies:server', 'connect', 'watch']);
grunt.registerTask('build', ['less', 'browserify', 'uglify']);
};