Transform compilerOptions.paths
alias to relative path;
For example:
before transformed
// src/app/index.ts
import util from "@/utils/util"
after transformed
import util from "../utils/util"
npm install esbuild-plugin-tsconfig-paths --dev
import { tsconfigPathsPlugin } from "esbuild-plugin-tsconfig-paths";
import esbuild from "esbuild";
esbuild.build({
// ...other config
plugins: [
// ... other plugins
tsconfigPathsPlugin({
// Directory of tsconfig file
cwd: process.cwd(),
// tsconfig filename
tsconfig: "custom-tsconfig.json",
// which files will be transformed
filter: /.*/,
})
]
})