-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
how to configure metro.config.js in 0.72.0 #276
Comments
same issue |
I have added something like this, metro its running now but I haven't confirmed if the app will work after a RN 0.72.0 upgrade const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
const defaultSourceExts = require('metro-config/src/defaults/defaults').sourceExts;
const defaultAssetExts = require('metro-config/src/defaults/defaults').assetExts;
/**
* Metro configuration
* https://facebook.github.io/metro/docs/configuration
*
* @type {import('metro-config').MetroConfig}
*/
module.exports = mergeConfig(getDefaultConfig(__dirname), {
transformer: {
babelTransformerPath: require.resolve('react-native-svg-transformer'),
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: true,
},
}),
},
resolver: {
assetExts: defaultAssetExts.filter(ext => ext !== 'svg'),
sourceExts: [...defaultSourceExts, 'svg'],
},
}); |
yes |
works like a charm |
Very helping bro, thank u so much. You save my life 😭 |
Thank you so much @jackfiallos, this works 100000% 🚀 |
this works for me. i have made a small change. i think the empty so alternatively, i have it like this: const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
const sourceExts = require('metro-config/src/defaults/defaults').sourceExts;
const assetExts = require('metro-config/src/defaults/defaults').assetExts;
/**
* Metro configuration
* https://facebook.github.io/metro/docs/configuration
*
* @type {import('metro-config').MetroConfig}
*/
const config = {
transformer: {
babelTransformerPath: require.resolve('react-native-svg-transformer'),
getTransformOptions: async () => {
return {
transform: {
experimentalImportSupport: false,
inlineRequires: true,
},
};
},
},
resolver: {
assetExts: assetExts.filter((ext) => { return ext !== 'svg'; }),
sourceExts: [...sourceExts, 'svg'],
},
};
module.exports = mergeConfig(getDefaultConfig(__dirname), config); |
Summary: Reverts facebook#36777. This is motivated by reducing user friction when the widespread assumption is for `react-native/metro-config` to export a complete Metro config, as with Expo/rnx-kit, and like previously understood uses of `metro-config`. See facebook/metro#1010 (comment) for further notes. Fixes: - facebook/metro#1010 - facebook#38069 - kristerkari/react-native-svg-transformer#276 Note that we do not intend for `react-native/metro-config` to directly export `assetExts` etc — these can be accessed on the `resolver` property from the full config object. Changelog: [General][Changed] `react-native/metro-config` now includes all base config values from `metro-config` Differential Revision: D47055973 fbshipit-source-id: 78b59d925be72aa42b4b9d901c6f8d174f2dbae0
Summary: Pull Request resolved: facebook#38092 Reverts facebook#36777. This is motivated by reducing user friction when the widespread assumption is for `react-native/metro-config` to export a complete Metro config, as with Expo/rnx-kit, and like previously understood uses of `metro-config`. See facebook/metro#1010 (comment) for further notes. Fixes: - facebook/metro#1010 - facebook#38069 - kristerkari/react-native-svg-transformer#276 Note that we do not intend for `react-native/metro-config` to directly export `assetExts` etc — these can be accessed on the `resolver` property from the full config object. Changelog: [General][Changed] `react-native/metro-config` now includes all base config values from `metro-config` Reviewed By: robhogan Differential Revision: D47055973 fbshipit-source-id: eedc4698e651645ada46a013d3945a16965bff22
Summary: Pull Request resolved: #38092 Reverts #36777. This is motivated by reducing user friction when the widespread assumption is for `react-native/metro-config` to export a complete Metro config, as with Expo/rnx-kit, and like previously understood uses of `metro-config`. See facebook/metro#1010 (comment) for further notes. Fixes: - facebook/metro#1010 - #38069 - kristerkari/react-native-svg-transformer#276 Note that we do not intend for `react-native/metro-config` to directly export `assetExts` etc — these can be accessed on the `resolver` property from the full config object. Changelog: [General][Changed] `react-native/metro-config` now includes all base config values from `metro-config` Reviewed By: robhogan Differential Revision: D47055973 fbshipit-source-id: 5ad23cc9700397110de5c0e81c7d76299761ef0a
Summary: Pull Request resolved: #38092 Reverts #36777. This is motivated by reducing user friction when the widespread assumption is for `react-native/metro-config` to export a complete Metro config, as with Expo/rnx-kit, and like previously understood uses of `metro-config`. See facebook/metro#1010 (comment) for further notes. Fixes: - facebook/metro#1010 - #38069 - kristerkari/react-native-svg-transformer#276 Note that we do not intend for `react-native/metro-config` to directly export `assetExts` etc — these can be accessed on the `resolver` property from the full config object. Changelog: [General][Changed] `react-native/metro-config` now includes all base config values from `metro-config` Reviewed By: robhogan Differential Revision: D47055973 fbshipit-source-id: 5ad23cc9700397110de5c0e81c7d76299761ef0a
I'll update the docs as soon as I have tested that everything works with the suggested config / PR 🙂 |
From React Native 0.72.1 (with const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
const defaultConfig = getDefaultConfig(__dirname);
const { assetExts, sourceExts } = defaultConfig.resolver;
/**
* Metro configuration
* https://facebook.github.io/metro/docs/configuration
*
* @type {import('metro-config').MetroConfig}
*/
const config = {
transformer: {
babelTransformerPath: require.resolve('react-native-svg-transformer'),
},
resolver: {
assetExts: assetExts.filter(ext => ext !== 'svg'),
sourceExts: [...sourceExts, 'svg'],
},
};
module.exports = mergeConfig(defaultConfig, config); |
@trmylinh Run |
when I run |
You should update |
yeah, I have done update version like that, but it throw same error T.T |
oh now it works, thank you so much |
https://github.com/kristerkari/react-native-svg-transformer/blob/master/README.md it is updated in README.md file. |
In addition to what was said above, I also had to run
|
This version they are changed metro config.
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config'); const config = {}; module.exports = mergeConfig(getDefaultConfig(__dirname), config);
The text was updated successfully, but these errors were encountered: