Skip to content

Commit

Permalink
fix: support ignoreBrowserslistConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
CyanSalt committed Feb 8, 2023
1 parent e6fed36 commit 747d4cf
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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[]`
Expand Down
6 changes: 5 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ export interface Options {
* default: 'defaults'
*/
targets?: string | string[] | Record<string, string>,
/**
* default: false
*/
ignoreBrowserslistConfig?: boolean,
/**
* default: true
*/
Expand Down

0 comments on commit 747d4cf

Please sign in to comment.