Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b1f9aee

Browse files
committed
feat: change devtools default value to false
1 parent 69a8c08 commit b1f9aee

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

src/index.ts

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -312,26 +312,28 @@ export function useVSCodePlugin(options?: PluginOptions): PluginOption {
312312
return html;
313313
}
314314

315-
const devtools = opts.devtools ?? true;
316-
let port: number | undefined;
317-
if (typeof devtools === 'number') {
318-
port = devtools;
319-
}
320-
else if (devtools === true) {
321-
if (resolvedConfig.plugins.find(s => ['vite:vue', 'vite:vue2'].includes(s.name))) {
322-
port = 8098;
315+
const devtools = opts.devtools;
316+
if (devtools) {
317+
let port: number | undefined;
318+
if (typeof devtools === 'number') {
319+
port = devtools;
323320
}
324-
else if (resolvedConfig.plugins.find(s => ['vite:react-refresh', 'vite:react-swc'].includes(s.name))) {
325-
port = 8097;
321+
else if (devtools === true) {
322+
if (resolvedConfig.plugins.find(s => ['vite:vue', 'vite:vue2'].includes(s.name))) {
323+
port = 8098;
324+
}
325+
else if (resolvedConfig.plugins.find(s => ['vite:react-refresh', 'vite:react-swc'].includes(s.name))) {
326+
port = 8097;
327+
}
326328
}
327-
}
328329

329-
if (port) {
330-
html = html.replace(/<head>/i, `<head><script src="http://localhost:${port}"></script>`);
331-
}
332-
else if (devtools && !devtoolsFlag) {
333-
devtoolsFlag = true;
334-
logger.warn('Only support react-devtools and vue-devtools!');
330+
if (port) {
331+
html = html.replace(/<head>/i, `<head><script src="http://localhost:${port}"></script>`);
332+
}
333+
else if (!devtoolsFlag) {
334+
devtoolsFlag = true;
335+
logger.warn('Only support react-devtools and vue-devtools!');
336+
}
335337
}
336338

337339
return html.replace(/<head>/i, `<head><script>${devWebviewClientCode}</script>`);

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export interface PluginOptions {
7474
* - react: inject `<script src="http://localhost:8097"></script>`
7575
* - vue: inject `<script src="http://localhost:8098"></script>`
7676
* - `number`: custom port
77-
* @default true
77+
* @default false
7878
*/
7979
devtools?: boolean | number;
8080
}

0 commit comments

Comments
 (0)