我正在使用babel-plugin-module-resolver来处理../../../
地狱。在我的.babelrc我有:
{
"presets": [
"react-native",
"babel-preset-react-native-stage-0/decorator-support",
"react-native-dotenv"
],
"env": {
"development": {
"plugins": [
["module-resolver", {
"cwd": "babelrc",
"extensions": [
".js",
".ios.js",
".android.js"
],
"alias": {
"@assets": "./src/assets",
"@features": "./src/features",
"@common": "./src/common",
"@config": "./src/config",
"@services": "./src/services"
}
}],
"transform-react-jsx-source"
]
}
}
}
示例用法:import { Text } from '@common'
这在开发模式下运行良好,但是当我尝试发布 Android .apk 文件时cd android && ./gradlew assembleRelease && cd ..
出现错误:
Unable to resolve module @common from /home/ppozniak/Projects/project-name/src/Root.js: Module does not exist in the module map
似乎 gradlew 没有使用我的 .babelrc?
版本
"babel-plugin-module-resolver": "^3.0.0",
"babel-preset-react-native": "^4.0.0",
"react-native": "0.50.3",
"react": "16.0.0",
提前致谢。