Skip to content

ukjinjang/tsconfig-paths-replace

Repository files navigation

tsconfig-paths-replace

npm CircleCI codecov Known Vulnerabilities npm-download license

Replace import alias paths to relative paths via tsconfig-paths.

Installation

$ yarn add --dev tsconfig-paths-replace

Getting started

Build and replace paths

Use && operator to run replace after transpile via tsc.

{
  "scripts": {
    "build": "tsc && tsconfig-paths-replace -s ./src"
  },
}

Watch changes

You can replace paths while run tsc in watch (-w, --watch) mode. Create new tsconfig.json file with different name (for now tsconfig.watch.json).

// tsconfig.watch.json
{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "incremental": true,
    "tsBuildInfoFile": "./buildcache/watch.tsbuildinfo"
    // ...
  }
}

With tsc-watch, you can use callback --onSuccess after transpile done. Put tsconfig-paths-replace script at success command.

{
  "scripts": {
    "watch": "tsc-watch -p tsconfig.watch.json --noClear --noColors --onSuccess \"tsconfig-paths-replace -p ./tsconfig.watch.json\"",
  },
}

Options

Usage: tsconfig-paths-replace [options]

Options:
  -V, --version         output the version number
  -p, --project <file>  path to tsconfig.json
  -c, --cwd <path>      current working directory
  -r, --root <path>     root path of source (or `compilerOptions.rootDir`)
  -o, --out <path>      path of transpiled code output directory (or `compilerOptions.outDir`)
  -e, --emit <path>     output dir for emitted files (use `out` path by default)
  -w, --watch           watch changes of output directory
  -h, --help            display help for command

About

Replace import alias paths to relative paths via tsconfig-paths

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published