-
Notifications
You must be signed in to change notification settings - Fork 17
/
webpack.config.browser.js
80 lines (77 loc) · 2 KB
/
webpack.config.browser.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
var path = require('path');
var webpack = require('webpack');
var ESLintPlugin = require('eslint-webpack-plugin');
var TerserPlugin = require('terser-webpack-plugin');
var NodePolyfillPlugin = require('node-polyfill-webpack-plugin');
const config = {
target: 'web',
// https://stackoverflow.com/a/34018909
entry: {
'soroban-client': path.resolve(__dirname, './src/browser.ts'),
'soroban-client.min': path.resolve(__dirname, './src/browser.ts')
},
resolve: {
fallback: {
crypto: require.resolve('crypto-browserify'),
stream: require.resolve('stream-browserify'),
buffer: require.resolve('buffer')
},
extensions: ['.ts', '.js']
},
output: {
clean: true,
library: {
name: 'SorobanClient',
type: 'umd',
umdNamedDefine: true
},
path: path.resolve(__dirname, './dist')
},
mode: process.env.NODE_ENV ?? 'development',
devtool: process.env.NODE_ENV === 'production' ? false : 'inline-source-map',
module: {
rules: [
{
test: /\.m?(ts|js)$/,
exclude: /node_modules\/(?!(stellar-base|js-xdr))/,
use: {
loader: 'babel-loader',
options: {
cacheDirectory: true
}
}
}
]
},
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
include: /\.min\.js$/,
terserOptions: {
format: {
ascii_only: true
}
}
})
]
},
plugins: [
// this must be first for karma to work (see line 5 of karma.conf.js)
new ESLintPlugin({
overrideConfigFile: path.resolve(__dirname, '.eslintrc.js')
}),
// Ignore native modules (sodium-native)
new webpack.IgnorePlugin({ resourceRegExp: /sodium-native/ }),
new NodePolyfillPlugin({
includeAliases: ['http', 'https'] // others aren't needed
}),
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer']
})
],
watchOptions: {
ignored: /(node_modules|coverage|lib|dist)/
}
};
module.exports = config;