diff --git a/README.md b/README.md index 5400e15..21a5d16 100644 --- a/README.md +++ b/README.md @@ -45,8 +45,7 @@ export default defineConfig({ | Option | Type | Default | Description | |---|---|---|---| -| `devtoolsInProd` | `boolean` | `false` | Inject devtools bridge in production bundle instead of only in development mode | -| `devToolsEnabled` | `boolean` | `true` | Inject devtools bridge | +| `devToolsEnabled` | `boolean` | `!isProduction` | Inject devtools bridge | | `prefreshEnabled` | `boolean` | `true` | Inject [Prefresh](https://github.com/preactjs/prefresh) for HMR | | `reactAliasesEnabled` | `boolean` | `true` | Aliases `react`, `react-dom` to `preact/compat` | | `babel` | `object` | | See [Babel configuration](#babel-configuration) | diff --git a/src/devtools.ts b/src/devtools.ts index 5df6706..7eb915a 100644 --- a/src/devtools.ts +++ b/src/devtools.ts @@ -7,13 +7,11 @@ import type { RollupFilter } from "./utils.js"; import { parseId } from "./utils.js"; export interface PreactDevtoolsPluginOptions { - devtoolsInProd?: boolean; devToolsEnabled?: boolean; shouldTransform: RollupFilter; } export function preactDevtoolsPlugin({ - devtoolsInProd, devToolsEnabled, shouldTransform, }: PreactDevtoolsPluginOptions): Plugin { @@ -39,8 +37,7 @@ export function preactDevtoolsPlugin({ configResolved(resolvedConfig) { config = resolvedConfig; - devToolsEnabled = - devToolsEnabled ?? (!config.isProduction || devtoolsInProd); + devToolsEnabled = devToolsEnabled ?? !config.isProduction; }, resolveId(url, importer = "") { diff --git a/src/index.ts b/src/index.ts index 7517dca..46efece 100644 --- a/src/index.ts +++ b/src/index.ts @@ -20,15 +20,9 @@ export type BabelOptions = Omit< >; export interface PreactPluginOptions { - /** - * Inject devtools bridge in production bundle instead of only in development mode. - * @default false - */ - devtoolsInProd?: boolean; - /** * Whether to use Preact devtools - * @default true + * @default !isProduction */ devToolsEnabled?: boolean; @@ -97,7 +91,6 @@ export interface PreactBabelOptions extends BabelOptions { // Taken from https://github.com/vitejs/vite/blob/main/packages/plugin-react/src/index.ts function preactPlugin({ - devtoolsInProd, devToolsEnabled, prefreshEnabled, reactAliasesEnabled, @@ -131,7 +124,6 @@ function preactPlugin({ exclude || [/node_modules/], ); - devtoolsInProd = devtoolsInProd ?? false; prefreshEnabled = prefreshEnabled ?? true; reactAliasesEnabled = reactAliasesEnabled ?? true; prerender = prerender ?? { enabled: false }; @@ -158,8 +150,7 @@ function preactPlugin({ }, configResolved(resolvedConfig) { config = resolvedConfig; - devToolsEnabled = - devToolsEnabled ?? (!config.isProduction || devtoolsInProd); + devToolsEnabled = devToolsEnabled ?? !config.isProduction; }, async transform(code, url) { // Ignore query parameters, as in Vue SFC virtual modules. @@ -238,9 +229,8 @@ function preactPlugin({ : []), jsxPlugin, preactDevtoolsPlugin({ - devtoolsInProd, devToolsEnabled, - shouldTransform, + shouldTransform }), ...(prefreshEnabled ? [prefresh({ include, exclude, parserPlugins: baseParserOptions })]