Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

fix(vite): use url for entry on windows #6355

Merged
merged 4 commits into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"postcss-url": "^10.1.3",
"rollup": "^2.77.2",
"rollup-plugin-visualizer": "^5.7.1",
"std-env": "^3.1.1",
"ufo": "^0.8.5",
"unplugin": "^0.8.1",
"vite": "~3.0.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/dev-bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export async function initViteDevBundler (ctx: ViteBuildContext, onBuild: () =>
// Build and watch
const _doBuild = async () => {
const start = Date.now()
const { code, ids } = await bundleRequest(options, resolve(ctx.nuxt.options.appDir, 'entry'))
const { code, ids } = await bundleRequest(options, '/entry.mjs')
await fse.writeFile(resolve(ctx.nuxt.options.buildDir, 'dist/server/server.mjs'), code, 'utf-8')
// Have CSS in the manifest to prevent FOUC on dev SSR
await writeManifest(ctx, ids.filter(isCSS).map(i => i.slice(1)))
Expand Down
6 changes: 6 additions & 0 deletions packages/vite/src/vite.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { pathToFileURL } from 'node:url'
import * as vite from 'vite'
import { resolve } from 'pathe'
import type { Nuxt } from '@nuxt/schema'
Expand All @@ -6,6 +7,7 @@ import { logger, isIgnored } from '@nuxt/kit'
import type { Options } from '@vitejs/plugin-vue'
import replace from '@rollup/plugin-replace'
import { sanitizeFilePath } from 'mlly'
import { isWindows } from 'std-env'
import { buildClient } from './client'
import { buildServer } from './server'
import virtual from './plugins/virtual'
Expand Down Expand Up @@ -84,6 +86,10 @@ export async function bundle (nuxt: Nuxt) {
)
}

if (isWindows) {
ctx.config.resolve.alias['/entry.mjs'] = pathToFileURL(ctx.config.resolve.alias['/entry.mjs']).href
danielroe marked this conversation as resolved.
Show resolved Hide resolved
}

// In build mode we explicitly override any vite options that vite is relying on
// to detect whether to inject production or development code (such as HMR code)
if (!nuxt.options.dev) {
Expand Down
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1880,6 +1880,7 @@ __metadata:
postcss-url: ^10.1.3
rollup: ^2.77.2
rollup-plugin-visualizer: ^5.7.1
std-env: ^3.1.1
ufo: ^0.8.5
unbuild: latest
unplugin: ^0.8.1
Expand Down