-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwebpack.config.cjs
More file actions
72 lines (69 loc) · 1.76 KB
/
webpack.config.cjs
File metadata and controls
72 lines (69 loc) · 1.76 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
const path = require('path');
const webpack = require('webpack');
const TerserPlugin = require('terser-webpack-plugin');
const CompressionPlugin = require("compression-webpack-plugin");
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const isDevelopment = process.env.NODE_ENV === 'dev';
const outputDir = path.resolve(__dirname, 'build/output');
function getBaseConfig(entry, filename) {
return {
target: 'node',
entry,
output: {
filename: `${filename}.js`,
path: outputDir,
},
mode: isDevelopment ? 'development' : 'production',
devtool: isDevelopment ? 'inline-source-map' : false,
resolve: {
extensions: ['.ts', '.js'],
fallback: {
canvas: false,
},
alias: {
'@transmute': path.resolve(__dirname, 'lib/bindings'),
},
},
module: {
rules: [
{
test: /\.ts$/,
use: 'ts-loader',
exclude: /node_modules/,
},
]
},
plugins: [
new webpack.ProgressPlugin(),
new webpack.DefinePlugin({
'process.env.JSAR_VERSION': JSON.stringify(require('./package.json').version),
}),
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1,
}),
new CompressionPlugin({
test: /\.js$/,
minRatio: Infinity,
algorithm: 'gzip',
}),
new BundleAnalyzerPlugin({
analyzerMode: 'static',
openAnalyzer: false,
reportFilename: `${filename}.report.html`,
}),
],
optimization: {
minimizer: [
new TerserPlugin(),
],
},
};
}
module.exports = [
{
...getBaseConfig('./lib/main.ts', 'jsar-client-entry'),
},
{
...getBaseConfig('./lib/webworkers/entry.ts', 'jsar-webworkers-entry'),
}
];