在 webpack.config.js 中配置别名
alias: {
// 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',
// 配置本地的路径
'@': path.resolve('src'),
'configure': path.resolve('src/configure/'),
'component': path.resolve('/src/component/'),
'modules': path.resolve('/src/modules/'),
'container': path.resolve('/src/container/'),
'actions': path.resolve('/src/actions/'),
'reducers': path.resolve('/src/reducers/'),
// Allows for better profiling with ReactDevTools
...(isEnvProductionProfile && {
'react-dom$': 'react-dom/profiling',
'scheduler/tracing': 'scheduler/tracing-profiling',
}),
...(modules.webpackAliases || {}),
},