Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/davidmyersdev/vite-plugin-externalize-deps
A configurable Vite plugin to help externalize your dependencies (including subpaths)
https://github.com/davidmyersdev/vite-plugin-externalize-deps
vite vite-plugin
Last synced: 16 days ago
JSON representation
A configurable Vite plugin to help externalize your dependencies (including subpaths)
- Host: GitHub
- URL: https://github.com/davidmyersdev/vite-plugin-externalize-deps
- Owner: davidmyersdev
- License: mit
- Created: 2022-08-26T18:28:27.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-03T23:37:56.000Z (12 months ago)
- Last Synced: 2024-04-14T13:08:49.126Z (7 months ago)
- Topics: vite, vite-plugin
- Language: TypeScript
- Homepage:
- Size: 38 MB
- Stars: 48
- Watchers: 2
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# vite-plugin-externalize-deps
A configurable Vite plugin to help externalize your dependencies (including [subpaths](https://nodejs.org/api/packages.html#subpath-patterns)).
## Getting Started
Install the package as a dev dependency.
```sh
# npm
npm install --save-dev vite-plugin-externalize-deps# pnpm
pnpm install --save-dev vite-plugin-externalize-deps# yarn
yarn add --dev vite-plugin-externalize-deps
```Add the plugin to your `vite.config.ts` file.
```ts
import { defineConfig } from 'vite'
import { externalizeDeps } from 'vite-plugin-externalize-deps'// https://vitejs.dev/config/
export default defineConfig({
plugins: [
externalizeDeps(),
],
})
```### Configuration
Pass an object to `externalizeDeps` to override the default configuration.
```ts
// These are the default values.
externalizeDeps({
deps: true,
devDeps: false,
except: [],
nodeBuiltins: true,
optionalDeps: true,
peerDeps: true,
useFile: join(process.cwd(), 'package.json'),
})
```To _include_ specific dependencies in your bundle, you can add exceptions with the `except` option.
```ts
externalizeDeps({
except: [
// Match exact values with strings.
'@some/obscure/dependency',
// Or match patterns with regular expressions.
/^@some\/obscure(?:\/.+)?$/,
],
})
```