Skip to content

Commit db3c3e8

Browse files
committed
fix(bundler-vite): fix fs path on windows (close #74)
1 parent c989314 commit db3c3e8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/@vuepress/bundler-vite/src/plugin/createPlugin.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Plugin } from 'vite'
22
import createVuePlugin from '@vitejs/plugin-vue'
33
import type { App } from '@vuepress/core'
4+
import { removeLeadingSlash } from '@vuepress/shared'
45
import { fs } from '@vuepress/utils'
56
import type { ViteBundlerOptions } from '../types'
67
import { createWorkaroundPlugin } from './createWorkaroundPlugin'
@@ -45,13 +46,15 @@ export const createPlugin = ({
4546
if (req.url!.endsWith('.html')) {
4647
res.statusCode = 200
4748
const template = fs.readFileSync(app.options.templateDev).toString()
48-
const clientEntry = app.dir.client('lib/client.js')
49+
const clientEntrySrc = `/@fs/${removeLeadingSlash(
50+
app.dir.client('lib/client.js')
51+
)}`
4952
res.end(
5053
template.replace(
5154
/<\/body>/,
5255
`${[
5356
`<script type="module" src="/@vite/client"></script>`,
54-
`<script type="module" src="/@fs${clientEntry}"></script>`,
57+
`<script type="module" src="${clientEntrySrc}"></script>`,
5558
].join('')}</body>`
5659
)
5760
)

0 commit comments

Comments
 (0)