forked from naver/billboard.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
77 lines (69 loc) · 1.57 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
const pkg = require("./package.json");
const path = require("path");
const webpack = require("webpack");
const StringReplacePlugin = require("string-replace-webpack-plugin");
const Stylish = require("webpack-stylish");
const WebpackMonitor = require("webpack-monitor");
const WebpackBar = require("webpackbar");
const config = {
entry: {
billboard: "./src/core.js",
},
output: {
path: path.resolve(__dirname, "dist"),
filename: "[name].js",
libraryTarget: "umd",
umdNamedDefine: true,
},
externals: (context, request, callback) => {
// every 'd3-*' import, will be externally required as 'd3'
if (/^d3-/.test(request)) {
return callback(null, "d3");
}
callback();
},
devtool: "cheap-module-source-map",
module: {
rules: [
{
test: /(\.js)$/,
exclude: /(node_modules)/,
loader: "babel-loader",
},
{
test: /(\.js)$/,
loader: StringReplacePlugin.replace({
replacements: [{
pattern: /#__VERSION__#/ig,
replacement: (match, p1, offset, string) => pkg.version
}]
})
}
]
},
plugins: [
new StringReplacePlugin(),
new webpack.optimize.ModuleConcatenationPlugin(),
new Stylish(),
new WebpackBar()
],
stats: "minimal",
mode: "none"
};
module.exports = () => {
const env = process.env;
let mode = "development";
if (env.NODE_ENV) {
mode = env.NODE_ENV;
}
env.MONITOR && config.plugins.push(
new WebpackMonitor({
launch: true
})
);
if (env.NIGHTLY) {
pkg.version = env.NIGHTLY;
}
mode === "packaged" && delete config.externals;
return require(`./config/webpack.config.${mode}.js`)(config);
};