A webpack resolve plugin for resolving tsconfig paths.
npm install --save-dev ts-paths-resolve-plugin
Configurate in webpack.config.js
:
const TsPathsResolvePlugin = require('ts-paths-resolve-plugin');
module.exports = {
resolve: {
extensions: [".ts", ".tsx", ".js", ".jsx", ".json"],
plugins: [new TsPathsResolvePlugin()],
}
}
tsconfig.json
example:
{
"compilerOptions": {
"paths": {
"~/*": ["./*"]
}
}
}
And you can import with alias instead of annoying path
// import App from "../../../../App"
import App from "~/App"
...
Specify set where your TypeScript configuration file.
If not set:
- use Environment variable TS_NODE_PROJECT
- or search tsconfig.json in current working directory.
Log level when the plugin is running.