-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathwebpack.config.js
62 lines (59 loc) · 1.84 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const production = process.env.NODE_ENV === 'production';
const TerserPlugin = require('terser-webpack-plugin');
const path = require('path');
const DeleteAssetsPlugin = require('./deletePlugin.plugin');
const LimitChunkCountPlugin = require('webpack/lib/optimize/LimitChunkCountPlugin');
module.exports = () => {
return {
entry: path.join(__dirname, './lib/src/index.js'),
output: {
filename: 'index.umd.js',
path: path.join(__dirname, 'dist'),
library: {
name: 'sdk_web',
type: 'umd'
}
},
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')
},
alias: {
bson: path.resolve(__dirname, '../../node_modules/bson/lib/bson.cjs')
}
},
externals: {
'@journeyapps/wa-sqlite': '@journeyapps/wa-sqlite',
'@journeyapps/wa-sqlite/src/examples/IDBBatchAtomicVFS.js':
'@journeyapps/wa-sqlite/src/examples/IDBBatchAtomicVFS.js',
'@powersync/common': '@powersync/common',
'async-mutex': 'async-mutex',
comlink: 'comlink',
'js-logger': 'js-logger',
lodash: 'lodash'
},
devtool: production ? 'source-map' : 'cheap-module-source-map',
mode: production ? 'production' : 'development',
optimization: {
minimizer: [new TerserPlugin()]
},
plugins: [
new LimitChunkCountPlugin({
maxChunks: 1 // There are issues with loading the dynamic BSON import, it works if the bson dependency is in the index bundle file
}),
new DeleteAssetsPlugin() // Add the custom plugin here
]
};
};