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

KittenUi + react-native-svg-transformer #1070

Closed
josef256 opened this issue May 8, 2020 · 2 comments
Closed

KittenUi + react-native-svg-transformer #1070

josef256 opened this issue May 8, 2020 · 2 comments

Comments

@josef256
Copy link

josef256 commented May 8, 2020

💬 Question

Hello,
i want to use react-native-svg-transformer with kittenUi, problem is i have a default kitten ui configuration wich create a metro.config.js file & in react-native-svg-transformer install steps i need to also edit that file.
here is kittenUi default metro.config.js file :

const MetroConfig = require('@ui-kitten/metro-config');
const evaConfig = {
evaPackage: '@eva-design/eva',
};
module.exports = MetroConfig.create(evaConfig, {
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: false,
},
}),
},
});

and here is the config i need to add:

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'],
},
};
})();

i trired to merge the two config it didn't work out.
any idea how to get those 2 along ?

thank you.

UI Kitten and Eva version

Package Version
@eva-design/eva 2.0.0-alpha.1
@ui-kitten/components 5.0.0-alpha.1
@artyorsh
Copy link
Collaborator

@josef256 thanks for posting this.

You don't need to merge it with UI Kitten config, since it is merged by @ui-kitten/metro-config package. Anyway, the trick was to functions and return a plain object.

This is how you can get this work.

const MetroConfig = require('@ui-kitten/metro-config');
const defaultConfig = require('metro-config/src/defaults').getDefaultValues();

/**
 * @see https://akveo.github.io/react-native-ui-kitten/docs/guides/improving-performance
 */
const evaConfig = {
  evaPackage: '@eva-design/eva',
};

module.exports = MetroConfig.create(evaConfig, {
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: false,
      },
    }),
    babelTransformerPath: require.resolve('react-native-svg-transformer'),
  },
  resolver: {
    assetExts: defaultConfig.resolver.assetExts.filter(ext => ext !== 'svg'),
    sourceExts: [...defaultConfig.resolver.sourceExts, 'svg']
  },
});

@josef256
Copy link
Author

thanks it worked ! (y)

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