-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
61 lines (57 loc) · 1.63 KB
/
webpack.config.js
File metadata and controls
61 lines (57 loc) · 1.63 KB
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
/* eslint-disable no-var, prefer-template */
var webpack = require("webpack");
module.exports = function webpackConfig(opts) {
var env = JSON.stringify(opts.args.production ? "production" : "development");
var config = {
entry: {
background: __dirname + "/app/scripts/background.js",
options: __dirname + "/app/scripts/options.js",
popup: __dirname + "/app/scripts/popup.js",
},
output: {
path: __dirname + "/dist/" + opts.args.vendor + "/scripts",
filename: "[name].js",
publicPath: "/scripts/",
},
plugins: [
new webpack.IgnorePlugin(/^(buffertools)$/),
new webpack.DefinePlugin({
__ENV__: env,
__VENDOR__: JSON.stringify(opts.args.vendor),
LIVERELOAD: opts.watch,
}),
new webpack.optimize.CommonsChunkPlugin("common-frontend.js", ["options", "popup"]),
new webpack.optimize.CommonsChunkPlugin("common.js"),
],
module: {
loaders: [
{
test: /\.js$/,
loader: "babel",
exclude: /(node_modules|bower_components)/,
query: {
cacheDirectory: true,
},
},
{
test: /\.json$/,
loader: "json",
},
],
},
devtool: opts.args.sourcemaps ? "inline-source-map" : null,
};
if (opts.args.production) {
config.plugins.push(
new webpack.optimize.DedupePlugin(),
new webpack.optimize.AggressiveMergingPlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: { warnings: false },
output: {
comments: require("uglify-save-license"),
},
})
);
}
return config;
};