-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathwebpack.config.js
More file actions
54 lines (52 loc) · 1.51 KB
/
Copy pathwebpack.config.js
File metadata and controls
54 lines (52 loc) · 1.51 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
const path = require("path");
const TerserPlugin = require("terser-webpack-plugin");
const nodeExternals = require("webpack-node-externals");
const pkg = require("./package.json");
// const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
const getConfig = (target) => {
return {
entry: "./lib/index.ts",
mode: "production",
module: {
rules: [
{
test: /\.tsx?$/,
use: "ts-loader",
exclude: /node_modules/,
},
],
},
plugins: [
// new BundleAnalyzerPlugin()
],
resolve: {
extensions: [".tsx", ".ts", ".js", ".json"],
},
output: {
filename: (target === "web" ? pkg.browser : pkg.main).replace(/.*\//g, ""),
path: path.resolve(__dirname, "dist"),
library: "proton-api",
libraryTarget: "umd",
},
optimization: {
minimizer: [
new TerserPlugin({
sourceMap: true,
parallel: true,
}),
],
},
node: target === "web" ? {
crypto: false,
} : undefined,
target: target === "web" ? "web" : "node",
externals: target === "web" ? undefined : [nodeExternals()],
devtool: "source-map",
};
};
module.exports = () => {
return [
getConfig("web"),
getConfig("node"),
];
};