如何将 `react-native-reanimated/plugin` 添加到 `babel.config.js` 中?

huangapple go评论90阅读模式
英文:

How to add `react-native-reanimated/plugin` to `babel.config.js`?

问题

我正在尝试将react-native-reanimatedv1.13.3升级到v2.0.1。在安装说明中,他们建议在您的babel.config.js中添加react-native-reanimated/plugin,如下所示:

  1. module.exports = {
  2. presets: [
  3. ...
  4. ],
  5. plugins: [
  6. ...
  7. 'react-native-reanimated/plugin',
  8. ],
  9. };

目前我的babel.config.js如下所示:

  1. module.exports = {
  2. presets: ['module:metro-react-native-babel-preset'],
  3. env: {
  4. production: {
  5. plugins: [
  6. 'react-native-paper/babel'
  7. ],
  8. },
  9. }
  10. };

如果我像这样添加它:

  1. plugins: [
  2. 'react-native-paper/babel'
  3. 'react-native-reanimated/plugin'
  4. ],

我会收到此错误:Transform's input file does not exist: <project>/node_modules/react-native-reanimated/android/react-native-reanimated-65.aar. (See https://issuetracker.google.com/issues/158753935)

我应该如何替代添加它?

英文:

I'm trying to upgrade react-native-reanimated from v1.13.3 to v2.0.1. In the installation instructions they say to add react-native-reanimated/plugin to your babel.config.js as follows:

  1. module.exports = {
  2. presets: [
  3. ...
  4. ],
  5. plugins: [
  6. ...
  7. &#39;react-native-reanimated/plugin&#39;,
  8. ],
  9. };

Currently my babel.config.js looks like this:

  1. module.exports = {
  2. presets: [&#39;module:metro-react-native-babel-preset&#39;],
  3. env: {
  4. production: {
  5. plugins: [
  6. &#39;react-native-paper/babel&#39;
  7. ],
  8. },
  9. }
  10. };

If I add it like this:

  1. plugins: [
  2. &#39;react-native-paper/babel&#39;
  3. &#39;react-native-reanimated/plugin&#39;
  4. ],

I get this error: Transform&#39;s input file does not exist: &lt;project&gt;/node_modules/react-native-reanimated/android/react-native-reanimated-65.aar. (See https://issuetracker.google.com/issues/158753935)

How should I add it instead?

答案1

得分: 2

module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
'react-native-reanimated/plugin',
],
env: {
production: {
plugins: [
'react-native-paper/babel'
],
},
}
};

英文:

You can try:

  1. module.exports = {
  2. presets: [&#39;module:metro-react-native-babel-preset&#39;],
  3. plugins: [
  4. &#39;react-native-reanimated/plugin&#39;,
  5. ],
  6. env: {
  7. production: {
  8. plugins: [
  9. &#39;react-native-paper/babel&#39;
  10. ],
  11. },
  12. }
  13. };

huangapple
  • 本文由 发表于 2023年2月24日 03:35:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/75549528.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定