Skip to content

Commit 8226809

Browse files
committed
release v0.3.0
1 parent be3ca6d commit 8226809

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

example/vue2/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"sass": "^1.49.9",
1515
"typescript": "^4.5.2",
1616
"vite": "2.9.1",
17-
"vite-plugin-vue-inspector": "0.2.7",
17+
"vite-plugin-vue-inspector": "0.3.0",
1818
"vite-plugin-vue2": "^1.9.3"
1919
}
2020
}

example/vue3/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
"sass": "^1.49.9",
1616
"typescript": "^4.5.2",
1717
"vite": "2.9.1",
18-
"vite-plugin-vue-inspector": "0.2.7"
18+
"vite-plugin-vue-inspector": "0.3.0"
1919
}
2020
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vite-plugin-vue-inspector",
3-
"version": "0.2.7",
3+
"version": "0.3.0",
44
"description": "jump to local IDE source code while click the element of browser automatically.",
55
"keywords": [
66
"vue",

src/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Plugin } from "vite"
22
import { compileSFCTemplate } from "./compiler"
3-
import { parseVueRequest, normalizeOverlayScripts } from "./utils"
3+
import { parseVueRequest, normalizeOverlayScripts, getVueDepsBrowserHash } from "./utils"
44
import { v2, v3 } from "./overlay/index.json"
55
import { queryParserMiddleware, launchEditorMiddleware } from "./middleware"
66

@@ -32,8 +32,6 @@ function VitePluginInspector(options: VitePluginInspectorOptions = { vue: 3, ena
3232
server.middlewares.use(launchEditorMiddleware)
3333
},
3434
transformIndexHtml(html, { server }) {
35-
const _server = server as any
36-
const browserHash = _server?._optimizedDeps?.metadata?.browserHash ?? _server?._optimizeDepsMetadata?.browserHash ?? ""
3735
return {
3836
html,
3937
tags: [{
@@ -46,7 +44,7 @@ function VitePluginInspector(options: VitePluginInspectorOptions = { vue: 3, ena
4644
type: "module",
4745
},
4846
children: normalizeOverlayScripts({
49-
hash: browserHash,
47+
hash: getVueDepsBrowserHash(server),
5048
scripts,
5149
}),
5250
injectTo: "body",

src/utils/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ export function parseVueRequest(id: string) {
3636
}
3737
}
3838

39+
export function getVueDepsBrowserHash(server: any) {
40+
// below vite 2.9
41+
if (server?._optimizeDepsMetadata?.browserHash)
42+
return server._optimizeDepsMetadata.browserHash
43+
else
44+
return server?._optimizedDeps?.metadata?.optimized?.vue?.browserHash ?? ""
45+
}
46+
3947
// vue.js deps add browserHash which that made hot reload work normal
4048
// e.g. node_modules/.vite/vue.js?v=9cc9e54f
4149
export function normalizeOverlayScripts({ hash, scripts }: { scripts: string; hash: string }) {

0 commit comments

Comments
 (0)