-
Notifications
You must be signed in to change notification settings - Fork 71
/
webpack.config.base.js
91 lines (84 loc) · 2.64 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
/**
* Base webpack config used across other specific configs
*/
import { dependencies as externals } from '../app/package.json';
import ExtendedDefinePlugin from 'extended-define-webpack-plugin';
import path from 'path';
import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin';
import webpack from 'webpack';
export const defaultNodePolyfillsForRenderer = {
path: require.resolve('path-browserify'),
stream: require.resolve('stream-browserify'),
crypto: require.resolve('crypto-browserify'),
os: require.resolve('os-browserify/browser'),
http: require.resolve('stream-http'),
zlib: require.resolve('browserify-zlib'),
assert: require.resolve('assert'),
fs: false,
perf_hooks: false,
};
// eslint-disable-next-line import/no-default-export
export default {
module: {
noParse: [/\.wasm$/],
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
cacheDirectory: true,
},
},
},
// Rule added to support `argon2-browser` library
{
test: /\.wasm$/,
// Tells WebPack that this module should be included as
// base64-encoded binary file and not as code
loader: 'base64-loader',
// Disables WebPack's opinion where WebAssembly should be,
// makes it think that it's not WebAssembly
//
// Error: WebAssembly module is included in initial chunk.
type: 'javascript/auto',
},
],
},
output: {
path: path.join(__dirname, '..', 'app'),
// https://github.com/webpack/webpack/issues/1114
libraryTarget: 'commonjs2',
},
/**
* Determine the array of extensions that should be used to resolve modules.
*/
resolve: {
extensions: ['.js', '.jsx', '.json', '.ts', '.tsx'],
modules: [path.join(__dirname, '..', 'app'), 'node_modules'],
plugins: [new TsconfigPathsPlugin()],
},
stats: { errorDetails: true },
plugins: [
new ExtendedDefinePlugin({
CONFIG: {
NODE_ENV: process.env.NODE_ENV,
PLAIN_HMR: process.env.PLAIN_HMR,
STX_NETWORK: process.env.STX_NETWORK,
DEBUG_PROD: process.env.DEBUG_PROD,
START_HOT: process.env.START_HOT,
PORT: process.env.PORT,
PULL_REQUEST: process.env.PULL_REQUEST,
BRANCH_NAME: process.env.BRANCH_NAME,
SHA: process.env.SHA,
PULL_REQUEST: process.env.PULL_REQUEST,
},
}),
new webpack.EnvironmentPlugin({
STX_NETWORK: process.env.STX_NETWORK || 'mainnet',
SEGMENT_WRITE_KEY: process.env.SEGMENT_WRITE_KEY || '',
SENTRY_DSN: process.env.SENTRY_DSN || '',
}),
],
};