Skip to content

VKCOM/swc-plugin-pre-paths

Repository files navigation

swc-plugin-pre-paths

A SWC plugin to use path mapping. This may be needed in other plugins.

Installation

npm:

npm i -D swc-plugin-pre-paths

yarn:

yarn add -D swc-plugin-pre-paths

You can check the compatibility of versions on https://plugins.swc.rs/

Usage

Via .swcrc

{
  "jsc": {
    "experimental": {
      "plugins": [
        [
          "swc-plugin-pre-paths",
          {
            "baseUrl": ".",
            "paths": {
              "app/*": ["./src/app/*"],
              "config/*": ["./src/app/_config/*"],
              "environment/*": ["./src/environments/*"],
              "shared/*": ["./src/app/_shared/*"],
              "helpers/*": ["./src/helpers/*"],
              "tests/*": ["./src/tests/*"]
            }
          }
        ]
      ]
    }
  }
}

Limits

This don't support multiple fall back locations.

{
  "paths": {
    "*": ["*", "generated/*"] // ⛔ don't support
  }
}