-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathwebpack.config.js
73 lines (67 loc) · 1.78 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
const webpack = require("webpack");
const path = require("path");
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
let cmdOpts = {};
for(let i = 0; i < process.argv.length; i++){
if(process.argv[i].startsWith("--")){
cmdOpts[process.argv[i].substr(2)] = process.argv[i+1];
i += 1;
}
}
let plugins = [
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1,
}),
new webpack.IgnorePlugin(/unorm/),
new BundleAnalyzerPlugin({
analyzerMode: "static",
reportFilename: path.resolve(path.join(__dirname, "test", "bundle-analysis", "index.html")),
openAnalyzer: false
})
];
plugins.push(new webpack.IgnorePlugin(/window/));
// Exclude node-fetch for web build
if(cmdOpts["target"] !== "node") {
plugins.push(new webpack.IgnorePlugin(/node-fetch-polyfill/));
plugins.push(new webpack.IgnorePlugin(/@eluvio\/crypto\/dist\/elv-crypto.bundle.node/));
} else {
plugins.push(new webpack.IgnorePlugin(/@eluvio\/crypto\/dist\/elv-crypto.bundle.js/));
}
module.exports = {
entry: "./dist/src/ElvClient.js",
output: {
path: path.resolve(__dirname, "dist"),
filename: "ElvClient-min-dev.js",
libraryTarget: "umd"
},
node: {
fs: "empty"
},
resolve: {
alias: {
// Force webpack to use *one* copy of bn.js instead of 8
"bn.js": path.resolve(path.join(__dirname, "node_modules", "bn.js"))
}
},
mode: "development",
devtool: cmdOpts["mode"] === "production" ? "" : "source-map",
plugins: plugins,
module: {
noParse: [
/sjcl\.js$/
],
rules: [
{
test: /\.(txt|bin|abi)$/i,
loader: "raw-loader"
},
{
test: /\.js$/,
loader: "babel-loader",
options: {
presets: ["@babel/preset-env"],
}
},
]
},
};