forked from Keeper-Wallet/Keeper-Wallet-Extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
61 lines (58 loc) · 1.45 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
const path = require('path');
const WebpackCustomActions = require('./scripts/WebpackCustomActionsPlugin');
const clearDist = require('./scripts/clearDist');
const conf = require('./scripts/webpack.config');
const getVersion = require('./scripts/getVersion');
const devConf = conf => ({
...conf,
mode: 'development',
devtool: 'cheap-module-inline-source-map',
module: {
...conf.module,
rules: [
{
enforce: 'pre',
test: /\.js$/,
exclude: [
'long',
'@waves/data-entities',
'@waves/money-like-to-node',
'@waves/node-api-js',
'@waves/ts-lib-crypto',
].map(
moduleName =>
new RegExp(path.join(__dirname, 'node_modules', moduleName))
),
loader: 'source-map-loader',
},
...conf.module.rules,
],
},
});
const prodConf = conf => ({
...conf,
mode: 'production',
devtool: 'source-map',
plugins: [
...conf.plugins,
new WebpackCustomActions({ onBuildStart: [clearDist] }),
],
});
module.exports = () => {
const version = getVersion();
if (!version) {
throw 'Build failed';
}
const isProduction = process.env.NODE_ENV === 'production';
const configFn = isProduction ? prodConf : devConf;
return configFn({
...conf({
version,
DIST: 'dist',
PLATFORMS: ['chrome', 'firefox', 'opera', 'edge'],
LANGS: ['en'],
PAGE_TITLE: 'Waves Keeper',
isProduction,
}),
});
};