在src根目录新建config-overrides.js自定义webpack配置。
安装 customize-cra
npm install customize-cra
const { override, addWebpackAlias } = require('customize-cra');
const path = require('path')
module.exports = override(
addWebpackAlias({
'@': path.resolve(__dirname, './src'),
'@components': path.resolve(__dirname, './src/components'),
'@utils': path.resolve(__dirname, './src/utils'),
})
);