Skip to content

Latest commit

 

History

History
46 lines (37 loc) · 733 Bytes

moduleresolver.md

File metadata and controls

46 lines (37 loc) · 733 Bytes

Module Resolver handbook

offical babel-plugin-module-resolver

Install Module Resolver package in the project

$    yarn add -D babel-plugin-module-resolver
1. Create jsconfig.json for VS Code Configure the path mapping
{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@assets": ["./src/assets"]
    }
  }
}
2. Specify the plugin in your .babelrc with the custom root or alias.
{
  "plugins": [
    [
      "module-resolver",
      {
        "root": ["."],
        "alias": {
          "@assets": "./src/assets",
        }
      }
    ]
  ]
}

Usage

import { Assets } from "@assets";