Skip to content

Commit cde49a9

Browse files
posvayyx990803
authored andcommitted
Fix components names on Windows (#264)
Fix #256
1 parent d8d8cd6 commit cde49a9

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/backend/index.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ import { highlight, unHighlight, getInstanceRect } from './highlighter'
55
import { initVuexBackend } from './vuex'
66
import { initEventsBackend } from './events'
77
import { stringify, classify, camelize } from '../util'
8+
import path from 'path'
9+
10+
// Use a custom basename functions instead of the shimed version
11+
// because it doesn't work on Windows
12+
function basename (filename, ext) {
13+
return path.basename(
14+
filename.replace(/^[a-zA-Z]:/, '').replace(/\\/g, '/'),
15+
ext
16+
)
17+
}
818

919
// hook should have been injected before this executes.
1020
const hook = window.__VUE_DEVTOOLS_GLOBAL_HOOK__
@@ -317,7 +327,7 @@ export function getInstanceName (instance) {
317327
}
318328
const file = instance.$options.__file // injected by vue-loader
319329
if (file) {
320-
return classify(require('path').basename(file).replace(/\.vue$/, ''))
330+
return classify(basename(file, '.vue'))
321331
}
322332
return instance.$root === instance
323333
? 'Root'

0 commit comments

Comments
 (0)