vite-plugin-ts-mono-alias
v1.1.8
Published
Vite plugin ts resolve for mono-repo projects.
Downloads
101
Maintainers
Readme
vite-plugin-ts-mono-alias
A vite plugin to resolve mono-repo packages from 'src' directory, therefor no need to build packages for easy debugging. :)
Usage
# npm
npm install vite-plugin-ts-mono-alias -D
# yarn
yarn add vite-plugin-ts-mono-alias -D
Configuration
// vite.config.ts
import tsMonoAlias from 'vite-plugin-ts-mono-alias';
import { defineConfig } from 'vite';
// https://vitejs.dev/config/
export default defineConfig(() => {
return {
// ...
plugins: [tsMonoAlias()],
// ...
};
});
Options
alias
Define alias for packages.
example:
// vite.config.ts
import tsMonoAlias from 'vite-plugin-ts-mono-alias';
import { defineConfig } from 'vite';
import { join } from 'path';
// https://vitejs.dev/config/
export default defineConfig(() => {
return {
// ...
plugins: [
tsMonoAlias({
alias: {
'@example/package-a': '../../../package-a/lib',
'@example/package-b': ({ dir }) => join(dir, 'index.ts'),
},
}),
],
// ...
};
});
ignorePackages
default: [process.cwd()]
Ignore packages from redirecting.
example:
// vite.config.ts
import tsMonoAlias from 'vite-plugin-ts-mono-alias';
import { defineConfig } from 'vite';
// https://vitejs.dev/config/
export default defineConfig(() => {
return {
// ...
plugins: [
tsMonoAlias({
ignorePackages: [
'package-a', // by package name
'../package-b', // by path
],
}),
],
// ...
};
});
exact
default false.
Exactly match the importee. Such as
import a from '@example/package-a';
- Will work.
import a from '@example/package-a/lib/foo';
- Will not work.
TODO
- test
License
MIT