rollup-plugin-tsconfig-paths
TypeScript icon, indicating that this package has built-in type declarations

1.5.2 • Public • Published

rollup-plugin-tsconfig-paths

Latest Version

Rollup plugin for resolving tsconfig paths

npm install --save-dev rollup-plugin-tsconfig-paths

rollup.config.js

import tsConfigPaths from "rollup-plugin-tsconfig-paths"
import nodeResolve from "@rollup/plugin-node-resolve"
import commonjs from "@rollup/plugin-commonjs"

export default {
  plugins: [
    tsConfigPaths(),
    nodeResolve({ extensions: [".tsx", ".ts", ".jsx", ".js", ".json", ...] }),
    commonjs(),
  ]
}

Example tsconfig.json

{
  "compilerOptions": {
    "jsx": "preserve",
    "module": "esnext",
    "moduleResolution": "node",
    "target": "esnext",
    "lib": ["esnext", "dom", "dom.iterable"],
    "types": ["react", "webpack-env"],
    "baseUrl": ".",
    "paths": {
      "~/*": ["./*"]
    }
  }
}

Then you can import alias instead of annoying path

// import App from "../../../../App"
import App from "~/App"

...

Options

tsConfigPath (string | string[])

Specify set where your TypeScript configuration file.

If not set:

  • use Environment variable TS_NODE_PROJECT
  • or search tsconfig.json in current working directory.

logLevel ("none" | "error" | "warn" | "info" | "debug" | "trace") (default: "info")

Log level when the plugin is running.

reference

Package Sidebar

Install

npm i rollup-plugin-tsconfig-paths

Weekly Downloads

13,807

Version

1.5.2

License

MIT

Unpacked Size

8.29 kB

Total Files

6

Last publish

Collaborators

  • lightyen