Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use react-native-svg-transformer with react-native-reanimated? #399

Open
iamrohitagg opened this issue Dec 9, 2024 · 1 comment

Comments

@iamrohitagg
Copy link

I am trying to change my metro.config.js file for the third step as recommended. But i have already changed my metro.config.js for react-native-svg-transformer, and if I do some changes the svg package does not work for me.
I am using this for showing my local svg in the mobile app.

Here is my metro.config.js

const {
  wrapWithReanimatedMetroConfig,
} = require("react-native-reanimated/metro-config");

/**
 * Metro configuration
 * https://facebook.github.io/metro/docs/configuration
 *
 * @type {import('metro-config').MetroConfig}
 */
const config = async () => {
  const defaultConfig = getDefaultConfig(__dirname);
  const {
    resolver: { sourceExts, assetExts },
  } = defaultConfig;

  return mergeConfig(defaultConfig, {
    transformer: {
      babelTransformerPath: require.resolve("react-native-svg-transformer"),
      getTransformOptions: async () => ({
        transform: {
          experimentalImportSupport: false,
          inlineRequires: true,
        },
      }),
    },
    resolver: {
      assetExts: assetExts.filter((ext) => ext !== "svg"),
      sourceExts: [...sourceExts, "svg"],
    },
  });
};

module.exports = config;
@kristerkari
Copy link
Owner

@iamrohitagg Thanks! Are you still having problems with this? One of the common problems is that the changes to the metro.config.js are not applied unless the Metro packager gets restarted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants