-
Notifications
You must be signed in to change notification settings - Fork 31
/
webpack.config.babel.js
46 lines (43 loc) · 1.1 KB
/
webpack.config.babel.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
const dotenv = require('dotenv');
const path = require('path');
const webpack = require('webpack');
dotenv.config();
const portisEnvVars = Object.keys(process.env)
.filter(key => key.startsWith('PORTIS'))
.reduce((agg, key) => {
agg[`process.env.${key}`] = JSON.stringify(process.env[key]);
return agg;
}, {});
export default () => [
{
mode: 'production',
entry: './es/index.js',
node: {
fs: 'empty',
},
output: {
path: path.resolve(__dirname, './umd'),
filename: 'index.js',
libraryTarget: 'umd',
globalObject: 'this',
library: 'Portis',
libraryExport: 'default',
},
module: {
rules: [
{
test: /\.(js)$/,
include: [
path.resolve(__dirname, 'src'),
path.resolve(__dirname, 'node_modules/@portis/web3-provider-engine'),
],
use: 'babel-loader',
},
],
},
plugins: [
new webpack.DefinePlugin(portisEnvVars),
...(Number(process.env.PORTIS_BUILD_SOURCE_MAPS) ? [new webpack.EvalSourceMapDevToolPlugin({})] : []),
],
},
];