kristerkari / react-native-svg-transformer

Import SVG files in your React Native project the same way that you would in a Web application.
MIT License
1.58k stars 115 forks source link

Anyone have new metro setup for react native 0.72.0 #271

Closed dungpasoftware closed 1 year ago

dungpasoftware commented 1 year ago

Currently, when I upgraded to version 0.72.0. The metro.config.js file looks like that

const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');

/**
 * Metro configuration
 * https://facebook.github.io/metro/docs/configuration
 *
 * @type {import('metro-config').MetroConfig}
 */
const config = {};

module.exports = mergeConfig(getDefaultConfig(__dirname), config);

And I don't know how to put the metro setup into the config. I tried to put the async() function into config, but it couldn't finds the assetExts.filter.

const { getDefaultConfig } = require("metro-config");

module.exports = (async () => {
  const {
    resolver: { sourceExts, assetExts }
  } = await getDefaultConfig();
  return {
    transformer: {
      babelTransformerPath: require.resolve("react-native-svg-transformer")
    },
    resolver: {
      assetExts: assetExts.filter(ext => ext !== "svg"),
      sourceExts: [...sourceExts, "svg"]
    }
  };
dungpasoftware commented 1 year ago

fixed in this issue: https://github.com/kristerkari/react-native-svg-transformer/issues/267