@itxch/vite-plugin-externalise-dependencies
v1.0.1
Published
A vite plugin which will externalise all packages in the dependencies field in package.json
Downloads
2,283
Readme
vite-plugin-externalise-dependencies
A Vite plugin that automatically externalizes all packages listed in the dependencies field of your package.json file.
Useful for building libraries that should not bundle their dependencies such as server side / node packages.
Installation
npm install @itxch/vite-plugin-externalise-dependencies --save-devUsage
Add the plugin to your vite.config.ts:
import { defineConfig } from "vite";
import externaliseDependencies from "@itxch/vite-plugin-externalise-dependencies";
export default defineConfig({
plugins: [externaliseDependencies()],
});How It Works
The plugin reads your project's package.json file and automatically adds all packages listed in the dependencies field to Vite's external configuration. This is useful when:
- Building libraries that should not bundle their dependencies
- Creating packages that rely on peer dependencies
- Reducing bundle size by excluding dependencies
Options
| Option | Type | Default | Description |
| ----------------- | -------- | --------------------- | ------------------------------------- |
| packageJsonPath | string | {root}/package.json | Custom path to your package.json file |
Requirements
- Node.js >= 22
- Vite >= 5
License
MIT
