Skip to content

Commit bed0b13

Browse files
committed
fix: console append
1 parent f7f97f2 commit bed0b13

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

src/console.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const warn = console.warn
22
console.warn = function (...data) {
3-
const skipMsgPrefix = "[Vue warn]: Extraneous non-props attributes ";
3+
const skipMsgPrefix = "[Vue warn]: Extraneous non-props attributes "
44
let msg = data[0] || ""
55
if (msg.startsWith(skipMsgPrefix)) {
66
msg = msg.replace(/\([^)]+\)/, function (match) {

src/index.ts

+18-16
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,13 @@ function VitePluginInspector(options: VitePluginInspectorOptions = DEFAULT_INSPE
113113
if (isJsx || isTpl)
114114
return compileSFCTemplate({ code, id: filename, type: isJsx ? "jsx" : "template", withComponent: normalizedOptions.withComponent })
115115

116-
if (normalizedOptions.appendTo && filename.endsWith(normalizedOptions.appendTo))
117-
return { code: `${code}\nimport 'virtual:vue-inspector-path:load.js'` }
116+
if (normalizedOptions.appendTo && filename.endsWith(normalizedOptions.appendTo)) {
117+
const libs = ["import 'virtual:vue-inspector-path:load.js'"]
118+
if (normalizedOptions.withComponent) {
119+
libs.push("import 'virtual:vue-inspector-path:console.js'")
120+
}
121+
return `${code}\n${libs.join('\n')}`
122+
}
118123

119124
return code
120125
},
@@ -131,21 +136,18 @@ function VitePluginInspector(options: VitePluginInspectorOptions = DEFAULT_INSPE
131136
transformIndexHtml(html) {
132137
if (normalizedOptions.appendTo)
133138
return
134-
const result: IndexHtmlTransformResult = {
135-
html,
136-
tags: [
137-
{
138-
tag: "script",
139-
injectTo: "body",
140-
attrs: {
141-
type: "module",
142-
src: "/@id/virtual:vue-inspector-path:load.js",
143-
},
139+
const tags = [
140+
{
141+
tag: "script",
142+
injectTo: "body" as const,
143+
attrs: {
144+
type: "module",
145+
src: "/@id/virtual:vue-inspector-path:load.js",
144146
},
145-
],
146-
}
147+
},
148+
]
147149
if (normalizedOptions.withComponent) {
148-
result.tags.push({
150+
tags.push({
149151
tag: "script",
150152
injectTo: "body",
151153
attrs: {
@@ -154,7 +156,7 @@ function VitePluginInspector(options: VitePluginInspectorOptions = DEFAULT_INSPE
154156
},
155157
})
156158
}
157-
return result
159+
return { html, tags }
158160
},
159161
}
160162
}

0 commit comments

Comments
 (0)