Snippet

Babel RC with Module Resolver Support

This BabelRC configuration for React and React Native comes with Module Resolver Support as well as the proper presets for web and mobile

Sunny Golovine


React Web

javascript

module.exports = {
  presets: [
    "babel-preset-gatsby",
    "@babel/preset-react",
    "@babel/preset-typescript",
  ],
  plugins: [
    [
      "module-resolver",
      {
        root: ["."],
        alias: {
          "~": "./src",
        },
      },
    ],
  ],
}

React Native

javascript

module.exports = {
  presets: ["module:metro-react-native-babel-preset"],
  plugins: [
    "babel-plugin-styled-components",
    [
      "module-resolver",
      {
        root: ["."],
        alias: {
          "~": "./src",
        },
      },
    ],
  ],
}

Copyright 2022, Sunny Golovine

Version: 1.2.0 (44875ce)