forked from webpack/analyse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
61 lines (59 loc) · 1.35 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
var path = require("path");
module.exports = function(grunt) {
require("matchdep").filterAll("grunt-*").forEach(grunt.loadNpmTasks);
var webpack = require("webpack");
grunt.initConfig({
webpack: {
options: require("./webpack.config.js"),
production: {
plugins: [
new webpack.DefinePlugin({
GA_TRACKING_CODE: JSON.stringify('UA-46921629-1'),
GA_TRACKING_CONFIG: JSON.stringify('webpack.github.io')
}),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin()
]
}
},
"webpack-dev-server": {
development: {
contentBase: "dist",
port: 8080,
keepAlive: true,
webpack: merge(require("./webpack.config.js"), {
devtool: "eval"
})
}
},
"gh-pages": {
options: {
message: "Publish",
base: "dist"
},
src: ["**"]
},
copy: {
main: {
src: "index.html",
dest: "dist/"
}
},
clean: ["dist"]
});
grunt.registerTask("development", ["copy", "webpack-dev-server:development"]);
grunt.registerTask("production", ["copy", "webpack:production"]);
grunt.registerTask("deploy", ["clean", "production", "gh-pages"]);
grunt.registerTask("dev", ["development"]);
grunt.registerTask("default", ["production"]);
};
function merge(a, b) {
var o = {};
for(var key in a) {
o[key] = a[key];
}
for(var key in b) {
o[key] = b[key];
}
return o;
}