Skip to content

Commit

Permalink
fix(fastify-vite): file path formats on Windows (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shyam-Chen committed Feb 29, 2024
1 parent 1a8c956 commit fc7b3af
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/fastify-vite/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ function resolveClientModule(root) {
function resolveRoot(path) {
let root = path
if (root.startsWith('file:')) {
root = fileURLToPath(root)
root = fileURLToPath(root).replace(/^file:\/\/\/([A-Z]):\//, 'file:///$1|/')
}
if (stat(root).isFile()) {
return dirname(root)
Expand All @@ -203,7 +203,7 @@ async function resolveViteConfig(root, dev, isSpa) {
mode,
)
if (process.platform === 'win32') {
configFile = `file://${configFile}`
configFile = `file://${configFile}`.replace(/^file:\/\/\/([A-Z]):\//, 'file:///$1|/')
}
let userConfig = await import(configFile).then((m) => m.default)
if (userConfig.default) {
Expand Down
4 changes: 2 additions & 2 deletions packages/fastify-vite/mode/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ async function setup(config) {
)
const ssrManifest =
process.platform === 'win32'
? new URL(fileUrl(ssrManifestPath))
? new URL(fileUrl(ssrManifestPath).replace(/^file:\/\/\/([A-Z]):\//, 'file:///$1|/'))
: ssrManifestPath
const serverFiles = [
join('server', `${parse(config.clientModule).name}.js`),
Expand All @@ -126,7 +126,7 @@ async function setup(config) {
// Use file path on Windows
serverBundlePath =
process.platform === 'win32'
? new URL(fileUrl(resolve(config.bundle.dir, serverFile)))
? new URL(fileUrl(resolve(config.bundle.dir, serverFile)).replace(/^file:\/\/\/([A-Z]):\//, 'file:///$1|/'))
: resolve(config.bundle.dir, serverFile)
if (await exists(serverBundlePath)) {
break
Expand Down

0 comments on commit fc7b3af

Please sign in to comment.