-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
48 lines (47 loc) · 1.47 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
const path = require('path');
const TerserPlugin = require('terser-webpack-plugin');
module.exports = {
entry: {
hack: './src/hack',
main: './src/main',
worker: './src/worker',
},
devtool: 'inline-source-map',
optimization: {
minimize: true,
minimizer: [new TerserPlugin()],
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'min'),
},
target: 'node',
mode: 'production',
resolve: {
extensions: ['.ts', '.js', '.tsx'],
},
module: {
rules: [
{ test: /\.tsx?$/, loader: 'ts-loader', options: { transpileOnly: true } },
{ test: /\.(js\.map|d\.ts)$/i, loader: 'ignore-loader' },
],
},
externals: [
({ request }, callback) => {
if (/^[@a-zA-Z0-9/_-]+/.test(request)) {
// 使用 request 路径,将一个 commonjs 模块外部化
return callback(null, `commonjs ${request}`);
}
if (/^[@a-zA-Z0-9/_-]+/.test(request)) {
// 使用 request 路径,将一个 commonjs 模块外部化
return callback(null, `commonjs ${request}`);
}
if (/\.json$/.test(request)) {
// 使用 request 路径,将一个 commonjs 模块外部化
return callback(null, `commonjs ${request}`);
}
callback();
},
{ canvas: "commonjs canvas" }
],
};