在项目根目录下创建config-overrides.js文件
const { override, fixBabelImports } = require('customize-cra');
const path = require("path")
module.exports = override(
fixBabelImports('import', {
libraryName: 'antd-mobile',
style: 'css',
}),
fixBabelImports('antd', {
libraryDirectory: 'es',
style: 'css',
}),
(config) => {
//暴露webpack的配置 config ,evn
const paths = require('react-scripts/config/paths');
// 配置打包目录输出到dist/web 目录中
paths.appBuild = path.join(path.dirname(paths.appBuild), 'dist/web');
config.output.path = paths.appBuild;
// 配置访问子目录/web/
paths.publicUrlOrPath = '/web/'
config.output.publicPath = '/web/'
return config
}
);