-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathwebpack.config.base.js
99 lines (96 loc) · 2.77 KB
/
webpack.config.base.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
87
88
89
90
91
92
93
94
95
96
97
98
99
// eslint-disable-next-line import/no-extraneous-dependencies
const { DefinePlugin, NormalModuleReplacementPlugin, ProvidePlugin, IgnorePlugin } = require('webpack');
const path = require('path');
const distDir = path.join(__dirname, 'dist');
// this is insecure, as it builds in your system's env variables. use webpack-dotenv or similar instead.
require('dotenv').config({ path: path.join(__dirname, '../../', '.env') });
module.exports = {
baseConfig: {
devtool: 'source-map',
externals: '@cardano-sdk/cardano-services',
ignoreWarnings: [/Failed to parse source map/],
mode: 'development',
module: {
// configuration regarding modules
rules: [
{
test: /docker\.js$/,
use: 'null-loader'
},
{
enforce: 'pre',
test: /\.js$/,
use: ['source-map-loader']
},
{
exclude: /node_modules/,
resolve: {
fullySpecified: false
},
test: /\.(js|ts)$/,
use: [
{
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', '@babel/preset-typescript']
}
}
]
}
]
},
output: {
filename: '[name].js',
path: distDir
},
plugins: [
new DefinePlugin({
'process.env': JSON.stringify(process.env)
}),
new NormalModuleReplacementPlugin(
/@dcspark\/cardano-multiplatform-lib-nodejs/,
'@dcspark/cardano-multiplatform-lib-browser'
),
new NormalModuleReplacementPlugin(
/@emurgo\/cardano-serialization-lib-nodejs/,
'@emurgo/cardano-serialization-lib-asmjs'
),
new NormalModuleReplacementPlugin(/blake2b$/, 'blake2b-no-wasm'),
new NormalModuleReplacementPlugin(
/@emurgo\/cardano-message-signing-nodejs/,
'@emurgo/cardano-message-signing-asmjs'
),
new ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
process: 'process/browser'
}),
new IgnorePlugin({
contextRegExp: /bip39\/src\/wordlists$/,
resourceRegExp: /^\.\/(?!english)/
})
],
resolve: {
extensions: ['.ts', '.js'],
fallback: {
'@cardano-sdk/cardano-services': false,
buffer: require.resolve('buffer/'),
crypto: require.resolve('crypto-browserify'),
events: require.resolve('events/'),
fs: false,
'get-port-please': false,
http: false,
net: false,
os: false,
path: false,
perf_hooks: false,
process: false,
stream: require.resolve('readable-stream'),
util: require.resolve('util/')
}
},
watchOptions: {
ignored: ['**/node_modules', distDir]
}
},
distDir
};