-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
112 lines (94 loc) · 2.06 KB
/
webpack.config.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
var webpack = require("webpack");
var yargs = require("yargs");
var path = require("path");
var argv = yargs
.boolean("p").alias("p", "optimize-minimize")
.boolean("h").alias("h", "hot")
.argv;
module.exports = {
entry: (function() {
var entry = [];
// if (argv.h) {
// entry.push("webpack-dev-server/client?/");
// entry.push("webpack/hot/dev-server");
// }
entry.push(path.join(__dirname, "src", "app", "entrypoints", "main.js"));
return {
main: entry
};
})(),
output: {
path: path.join(__dirname, "dist", "app"),
filename: "[name].js",
publicPath: "/app/"
},
module: {
loaders: [
{
test: /\.js$/,
exclude: [/node_modules/],
loaders: ["babel"]
},
{
test: /\.scss$/,
loaders: [
"style",
"css",
// "sass?outputStyle=expanded&" +
"sass?" +
"includePaths[]=" +
(path.join(__dirname, "node_modules"))
]
},
{
test: /\.css$/,
loaders: [
"style",
"css",
"autoprefixer?browsers=last 2 version"
]
},
{
test: /\.(ttf|eot|woff|svg)$/,
loaders: [
"file"
]
}
]
},
resolve: {
extensions: ["", ".js"],
root: path.join(__dirname, "src", "app"),
modulesDirectories: ["web_modules", "node_modules", "src"]
},
cache: !argv.p,
debug: !argv.p,
devtool: !argv.p ? "eval-cheap-module-source-map" : false,
stats: {
colors: true,
reasons: !argv.p
},
plugins: (function() {
var plugins = [];
plugins.push(
new webpack.DefinePlugin({
"process.env.NODE_ENV": JSON.stringify(argv.p ? "production" : "development"),
"__DEV__": !argv.p
})
);
if (argv.p) {
plugins.push(new webpack.optimize.DedupePlugin());
plugins.push(new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}));
plugins.push(new webpack.optimize.OccurenceOrderPlugin());
plugins.push(new webpack.optimize.AggressiveMergingPlugin());
}
if (argv.h) {
plugins.push(new webpack.NoErrorsPlugin());
}
return plugins;
})()
};