-
Notifications
You must be signed in to change notification settings - Fork 57
/
webpack.config.cjs
85 lines (73 loc) · 1.87 KB
/
webpack.config.cjs
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
const path = require("path");
const exec = require("child_process").exec;
const { DefinePlugin } = require("webpack");
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
const ResolveTypeScriptPlugin = require("resolve-typescript-plugin");
const SOURCE = path.resolve(__dirname, "./source");
const WEB_ENTRY = path.join(SOURCE, "index.web.ts");
const DIST = path.resolve(__dirname, "./dist/web");
const plugins = [
new DefinePlugin({
BUTTERCUP_WEB: true
})
];
if (process.env.ANALYSE === "bundle") {
plugins.push(new BundleAnalyzerPlugin());
}
const baseConfig = {
devtool: false,
entry: WEB_ENTRY,
experiments: {
outputModule: true
},
externalsType: "module",
module: {
rules: [
{
test: /(iconv-loader|bluebird|form-data)/,
use: "null-loader"
},
{
test: /\.ts$/,
exclude: /node_modules/,
use: {
loader: "ts-loader",
options: {
configFile: path.resolve(__dirname, "./tsconfig.web.json"),
onlyCompileBundledFiles: true
}
}
}
]
},
output: {
path: DIST,
filename: "index.js",
environment: {
module: true
},
library: {
type: "module"
}
},
plugins,
resolve: {
extensions: [".js"],
fallback: {
crypto: false,
dns: false,
fs: false,
http: false,
https: false,
net: false,
path: false,
stream: false,
util: false
},
plugins: [
new ResolveTypeScriptPlugin()
]
},
target: "web"
};
module.exports = baseConfig;