-
Notifications
You must be signed in to change notification settings - Fork 85
/
config-overrides.js
53 lines (47 loc) · 1.82 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
const webpack = require('webpack');
const path = require('path');
module.exports = {
paths: function (paths, env) {
paths.appPublic = path.resolve(__dirname, 'client/public');
paths.appHtml = path.resolve(__dirname, 'client/public/index.html');
paths.appIndexJs = path.resolve(__dirname, 'client/src/index.js');
paths.appSrc = path.resolve(__dirname, 'client/src');
paths.appBuild = path.resolve(__dirname, 'client/build');
return paths;
},
devServer: function(configFunction) {
return function(proxy, allowedHost) {
const config = configFunction(proxy, allowedHost);
// 确保 allowedHosts 包含非空字符串
config.allowedHosts = ['localhost'];
return config;
};
},
webpack: function (config, env) {
config.resolve = {
extensions: ['.js', '.jsx'],
alias: {
'process/browser': require.resolve('process/browser'),
},
fallback: {
zlib: require.resolve('browserify-zlib'),
stream: require.resolve('stream-browserify'),
crypto: require.resolve('crypto-browserify'),
assert: require.resolve('assert'),
http: require.resolve('stream-http'),
https: require.resolve('https-browserify'),
os: require.resolve('os-browserify/browser'),
url: require.resolve('url'),
process: require.resolve('process/browser'),
},
};
config.plugins.push(
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
process: 'process/browser',
qs: ['qs', 'default'] // 确保使用默认导出
})
);
return config;
}
};