-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathwebpack.workers.config.js
52 lines (50 loc) · 1.41 KB
/
webpack.workers.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
const production = process.env.NODE_ENV === 'production';
const TerserPlugin = require('terser-webpack-plugin');
const path = require('path');
const DeleteAssetsPlugin = require('./deletePlugin.plugin');
module.exports = () => {
return {
entry: {
SharedSyncImplementation: path.join(__dirname, './lib/src/worker/sync/SharedSyncImplementation.worker.js'),
WASQLiteDB: path.join(__dirname, './lib/src/worker/db/WASQLiteDB.worker.js')
},
experiments: {
topLevelAwait: true // Enable top-level await in Webpack
},
output: {
filename: 'worker/[name].umd.js',
path: path.join(__dirname, 'dist'),
library: {
name: 'sdk_web',
type: 'var'
}
},
target: 'webworker',
module: {
rules: [
{
enforce: 'pre',
test: /\.js$/,
loader: 'source-map-loader'
}
]
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
fallback: {
crypto: require.resolve('crypto-browserify'),
stream: require.resolve('stream-browserify'),
vm: require.resolve('vm-browserify')
}
},
devtool: production ? 'source-map' : 'cheap-module-source-map',
mode: production ? 'production' : 'development',
optimization: {
splitChunks: false,
minimizer: [new TerserPlugin()]
},
plugins: [
new DeleteAssetsPlugin() // Add the custom plugin here
]
};
};