1、执行命令
npm run eject
npm run eject 命令无法撤销
执行后,会出现config 和scripts 两个文件夹
2、找到暴露的config 下的 webpack.config.js 文件,在alias插入:
'@': path.resolve('src'),
alias: {
'@': path.resolve('src'),
// Support React Native Web
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
'react-native': 'react-native-web',
// Allows for better profiling with ReactDevTools
...(isEnvProductionProfile && {
'react-dom$': 'react-dom/profiling',
'scheduler/tracing': 'scheduler/tracing-profiling',
}),
...(modules.webpackAliases || {}),
},