@praha/vite-plugin-external
v1.2.0
Published
A Vite plugin that automatically excludes Node.js built-in modules and npm dependencies from the bundle
Readme
@praha/vite-plugin-external
A Vite plugin that automatically excludes Node.js built-in modules and npm dependencies from the bundle.
👏 Getting Started
Installation
npm install @praha/vite-plugin-externalUsage
To use @praha/vite-plugin-external, import and add it to the plugins array in your Vite configuration file:
Basic Usage
By default, this plugin will exclude:
- Node.js built-in modules
- Dependencies listed in package.json
import { externalPlugin } from '@praha/vite-plugin-external';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [
externalPlugin(),
],
});With Options
You can customize the behavior of the plugin by passing an options object:
import { externalPlugin } from '@praha/vite-plugin-external';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [
externalPlugin({
packageJsonPath: './path/to/package.json', // Specify a custom package.json path
include: ['some-package', /^@scoped\/.*$/], // Explicitly externalize specific packages
exclude: ['some-lib'], // Do not externalize certain packages
}),
],
});Options
| Name | Type | Description |
|-------------------|---------------------------------------------------|--------------------------------------------------------------------------------------|
| packageJsonPath | string | Path to a custom package.json file. Defaults to the project's root package.json. |
| include | string | RegExp | Array<string \| RegExp> | Packages to always externalize. |
| exclude | string | RegExp | Array<string \| RegExp> | Packages to explicitly prevent from being externalized. |
🤝 Contributing
Contributions, issues and feature requests are welcome.
Feel free to check issues page if you want to contribute.
📝 License
Copyright © PrAha, Inc.
This project is MIT licensed.
