forked from webpack/webpack-with-common-libs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
60 lines (57 loc) · 1.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
module.exports = function(grunt) {
require("matchdep").filterAll("grunt-*").forEach(grunt.loadNpmTasks);
var webpack = require("webpack");
var webpackConfig = require("./webpack.config.js");
grunt.initConfig({
webpack: {
options: webpackConfig,
build: {
plugins: webpackConfig.plugins.concat(
new webpack.DefinePlugin({
"process.env": {
// This has effect on the react lib size
"NODE_ENV": JSON.stringify("production")
}
}),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin()
)
},
"build-dev": {
devtool: "sourcemap",
debug: true
}
},
"webpack-dev-server": {
options: {
webpack: webpackConfig,
publicPath: "/" + webpackConfig.output.publicPath
},
start: {
keepAlive: true,
webpack: {
devtool: "eval",
debug: true
}
}
},
watch: {
app: {
files: ["app/**/*", "web_modules/**/*"],
tasks: ["webpack:build-dev"],
options: {
spawn: false,
}
}
}
});
// The development server (the recommended option for development)
grunt.registerTask("default", ["webpack-dev-server:start"]);
// Build and watch cycle (another option for development)
// Advantage: No server required, can run app from filesystem
// Disadvantage: Requests are not blocked until bundle is available,
// can serve an old app on too fast refresh
grunt.registerTask("dev", ["webpack:build-dev", "watch:app"]);
// Production build
grunt.registerTask("build", ["webpack:build"]);
};