forked from yours-org/yours-wallet
-
Notifications
You must be signed in to change notification settings - Fork 12
/
config-overrides.js
59 lines (52 loc) · 1.52 KB
/
config-overrides.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
const webpack = require('webpack');
const WebpackPluginReplaceNpm = require('replace-module-webpack-plugin');
const path = require('path');
module.exports = function override(config) {
config.resolve.extensions.push('.ts', '.tsx');
config.module.rules.push({
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
});
config.resolve.fallback = {
...config.resolve.fallback,
crypto: require.resolve('crypto-browserify'),
util: require.resolve('util'),
assert: require.resolve('assert'),
url: require.resolve('url'),
stream: require.resolve('stream-browserify'),
buffer: require.resolve('buffer'),
process: require.resolve('process'),
fs: false,
os: false,
};
config.plugins = [
...config.plugins,
new WebpackPluginReplaceNpm({
rules: [
{
originModule: 'path',
replaceModule: 'path-browserify',
},
],
}),
new webpack.ProvidePlugin({
process: 'process/browser.js',
Buffer: ['buffer', 'Buffer'],
}),
];
// Ensure the default entry point is included
config.entry = {
main: path.resolve(__dirname, 'src/index.tsx'),
background: path.resolve(__dirname, 'src/background.ts'),
content: path.resolve(__dirname, 'src/content.ts'),
inject: path.resolve(__dirname, 'src/inject.ts'),
};
// Ensure output configuration includes the background script
config.output = {
...config.output,
filename: '[name].js',
path: path.resolve(__dirname, 'build'),
};
return config;
};