-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathwebpack.inpage.js
87 lines (82 loc) · 2.44 KB
/
webpack.inpage.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
const path = require('path');
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');
const { DefinePlugin } = require('webpack');
const fs = require('fs');
const svgPath = path.resolve(__dirname, 'src/images/favicon.svg');
const svgCoreIcon = fs.readFileSync(svgPath, 'base64');
const devEvmProviderConfig = {
EVM_PROVIDER_INFO_NAME: '"Core Dev"',
EVM_PROVIDER_INFO_UUID: '"b11db586-a24d-4d95-81c1-62bb8e9da7b5"',
EVM_PROVIDER_INFO_ICON: JSON.stringify(
`data:image/svg+xml;base64,${svgCoreIcon}`
),
EVM_PROVIDER_INFO_DESCRIPTION: '"Core Dev Browser Extension"',
EVM_PROVIDER_INFO_RDNS: '"app.core.extension"',
};
const prodEvmProviderConfig = {
EVM_PROVIDER_INFO_NAME: '"Core"',
EVM_PROVIDER_INFO_UUID: '"eafb8ae4-8535-48df-b8c1-e69b999c367d"',
EVM_PROVIDER_INFO_ICON: JSON.stringify(
`data:image/svg+xml;base64,${svgCoreIcon}`
),
EVM_PROVIDER_INFO_DESCRIPTION: '"Core | Crypto Wallet & NFT Extension"',
EVM_PROVIDER_INFO_RDNS: '"app.core.extension"',
};
module.exports = (env, argv) => {
const isDevBuild = argv.mode !== 'production';
const evmProviderConfig = isDevBuild
? devEvmProviderConfig
: prodEvmProviderConfig;
return {
mode: 'development',
devtool: 'hidden-source-map',
entry: {
inpage: path.join(__dirname, 'src/inpage.js'),
},
output: {
path: path.join(__dirname, 'dist/js'),
filename: '[name].js',
},
module: {
rules: [
{
test: /\.(js|ts|tsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: [
'@babel/preset-typescript',
[
'@babel/preset-env',
{
targets: {
browsers: ['last 2 Chrome versions'],
},
modules: false,
},
],
],
plugins: ['@babel/transform-runtime'],
},
},
},
],
},
resolve: {
extensions: ['.ts', '.tsx', '.js'],
alias: {},
symlinks: false,
},
plugins: [
new NodePolyfillPlugin(),
new DefinePlugin({
...evmProviderConfig,
// For non-dev builds, it's replaced by actual version number later in the release process
CORE_EXTENSION_VERSION: isDevBuild
? '"0.0.0"'
: '"CORE_EXTENSION_VERSION"',
}),
],
};
};