-
Notifications
You must be signed in to change notification settings - Fork 0
/
config-overrides.js
66 lines (58 loc) · 1.89 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
60
61
62
63
64
65
66
// 修改webpack默认配置,目的:按需引入antdesign
// 、、customize-cra包含很多api
const {override, fixBabelImports, addWebpackAlias, removeModuleScopePlugin, addLessLoader,addPostcssPlugins, overrideDevServer,} = require('customize-cra');
const path = require("path")
const rewiredMap = () => config => {
config.devtool = config.mode === 'development' ? 'cheap-module-source-map' : false
return config
}
const devServerConfig = () => config => {
config.open = false;
config.compress = false;
config.proxy={
'/api': {
target: 'xxx',
changeOrigin: true,
pathRewrite: {
'^/api': '/api',
},
}
};
return config
}
module.exports = {
webpack: override(
addLessLoader(),
addPostcssPlugins([
/*require('postcss-normalize')({
forceImport: true
}),
require('postcss-preset-env')({
stage: 0
})*/
]),
rewiredMap(),
removeModuleScopePlugin(),
addWebpackAlias({ //路径别名
'@': path.resolve(__dirname, 'src'),
}),
// rewiredMap(),
(config) => {
if (process.env.BUILD_DOC === "true") {
//暴露webpack的配置 config ,evn
console.log(config.pluins)
const paths = require('react-scripts/config/paths');
// 配置打包目录输出到dist/web 目录中
paths.appBuild = path.join(path.dirname(paths.appBuild), 'docs');
config.output.path = paths.appBuild
// 配置访问子目录/web/
// paths.publicUrlOrPath = '/s-ui/'
config.output.publicPath = "/s-ui/"
}
return config
}
),
devServer: overrideDevServer(
devServerConfig()
)
}