diff --git a/README.md b/README.md index 88269a5..1959c34 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,18 @@ npm add -D terser Note: if additional polyfills are needed for both the modern and legacy chunks, they can simply be imported in the application source code. +### `ignoreBrowserslistConfig` + +- **Type:** `boolean` +- **Default:** `false` + + The legacy plugin automatically detects [`browserslist` config sources](https://github.com/browserslist/browserslist#browserslist-): + + - `browserslist` field in `package.json` + - `.browserslistrc` file in cwd. + + Set to `false` to ignore these sources. + ### `modernPolyfills` - **Type:** `boolean | string[]` diff --git a/src/index.ts b/src/index.ts index 8f40e01..3c929e7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -304,7 +304,11 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] { targets = options.targets // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - || browserslistLoadConfig({ path: resolvedConfig.root }) + || ( + options.ignoreBrowserslistConfig + ? undefined + : browserslistLoadConfig({ path: resolvedConfig.root }) + ) // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing || 'last 2 versions and not dead, > 0.3%, Firefox ESR' if (isDebug) { diff --git a/src/types.ts b/src/types.ts index a6df304..deba36e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -3,6 +3,10 @@ export interface Options { * default: 'defaults' */ targets?: string | string[] | Record, + /** + * default: false + */ + ignoreBrowserslistConfig?: boolean, /** * default: true */