-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathwebpack.config.js
86 lines (85 loc) · 3.03 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
const path = require('path');
const webpack = require('webpack');
const TerserPlugin = require('terser-webpack-plugin');
module.exports = function(env, argv) {
const isProduction = argv.mode === 'production';
return {
entry: './src/index.ts',
module: {
rules: [
{
test: /\.ts?$/,
use: [
{
loader: require.resolve('ts-loader'),
options: {
compiler: 'ts-patch/compiler',
},
},
],
exclude: ['/node_modules', '/lib'],
},
{
test: /\.m?js/,
resolve: {
fullySpecified: false
}
}
]
},
plugins: [
new webpack.IgnorePlugin({
checkResource(resource) {
// "@ethereumjs/common/genesisStates" consists ~800KB static files which are no more needed
return /(.*\/genesisStates\/.*\.json)/.test(resource)
},
}),
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
process: 'process/browser'
}),
new webpack.SourceMapDevToolPlugin({
test: [/\.ts$/],
exclude: 'vendor',
filename: "app.[hash].js.map",
append: "//# sourceMappingURL=[url]",
moduleFilenameTemplate: '[resource-path]',
fallbackModuleFilenameTemplate: '[resource-path]',
}),
],
resolve: {
extensions: ['.ts', '.js'],
alias: {
"src": path.resolve(__dirname, 'src'),
// To avoid blotting up the `bn.js` library all over the packages
// use single library instance.
"bn.js": path.resolve(__dirname, 'node_modules/bn.js')
},
fallback: {
"path": false,
"os": false,
"url": require.resolve("url"),
"http": require.resolve("http-browserify"),
"https": require.resolve("https-browserify"),
"stream": require.resolve("stream-browserify"),
"crypto": require.resolve("crypto-browserify"),
"querystring": require.resolve('querystring-es3'),
"zlib": require.resolve('browserify-zlib'),
"vm": require.resolve('vm-browserify')
}
},
output: {
filename: 'rubic-sdk.min.js',
path: path.resolve(__dirname, 'dist'),
library: "RubicSDK",
clean: true
},
// optimization: {
// minimizer: [new TerserPlugin({
// extractComments: false
// })],
// },
devtool: 'source-map',
mode: 'development',
}
};