How to use the metro-config/src/defaults/defaults.assetExts function in metro-config

To help you get started, we’ve selected a few metro-config examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github facebook / metro / packages / metro / src / ModuleGraph / worker / transform-module.js View on Github external
transformer: Transformer,
  variants?: TransformVariants,
|};

const NODE_MODULES = path.sep + 'node_modules' + path.sep;
const defaultTransformOptions = {
  dev: false,
  hot: false,
  inlineRequires: false,
  minify: true,
  platform: '',
  projectRoot: '',
};
const defaultVariants = {default: {}};

const ASSET_EXTENSIONS = new Set(defaults.assetExts);

function transformModule(
  content: Buffer,
  options: TransformOptions,
): TransformedSourceFile {
  const ext = path.extname(options.filename).substr(1);
  if (ASSET_EXTENSIONS.has(ext)) {
    return transformAsset(content, options.filename);
  }
  if (ext === 'json') {
    return transformJSON(content.toString('utf8'), options);
  }
  if (!options.sourceExts.has(ext)) {
    return {type: 'unknown'};
  }
github berty / berty / js / metro.config.js View on Github external
/**
 * Metro configuration for React Native
 * https://github.com/facebook/react-native
 *
 * @format
 */

const defaultAssetExts = require('metro-config/src/defaults/defaults').assetExts
const defaultSourceExts = require('metro-config/src/defaults/defaults').sourceExts
const exclusionList = require('metro-config/src/defaults/exclusionList')

module.exports = {
	transformer: {
		getTransformOptions: async () => ({
			transform: {
				experimentalImportSupport: false,
				inlineRequires: false,
			},
		}),
		babelTransformerPath: require.resolve('react-native-svg-transformer'),
	},
	resolver: {
		extraNodeModules: require('node-libs-react-native'),
		assetExts: defaultAssetExts.filter((ext) => ext !== 'svg'),