@@ -39,6 +39,7 @@ import {
39
39
isDataUrl ,
40
40
isExternalUrl ,
41
41
isObject ,
42
+ joinUrlSegments ,
42
43
normalizePath ,
43
44
parseRequest ,
44
45
processSrcSet ,
@@ -211,7 +212,7 @@ export function cssPlugin(config: ResolvedConfig): Plugin {
211
212
if ( encodePublicUrlsInCSS ( config ) ) {
212
213
return publicFileToBuiltUrl ( url , config )
213
214
} else {
214
- return config . base + url . slice ( 1 )
215
+ return joinUrlSegments ( config . base , url )
215
216
}
216
217
}
217
218
const resolved = await resolveUrl ( url , importer )
@@ -249,7 +250,6 @@ export function cssPlugin(config: ResolvedConfig): Plugin {
249
250
// server only logic for handling CSS @import dependency hmr
250
251
const { moduleGraph } = server
251
252
const thisModule = moduleGraph . getModuleById ( id )
252
- const devBase = config . base
253
253
if ( thisModule ) {
254
254
// CSS modules cannot self-accept since it exports values
255
255
const isSelfAccepting =
@@ -258,6 +258,7 @@ export function cssPlugin(config: ResolvedConfig): Plugin {
258
258
// record deps in the module graph so edits to @import css can trigger
259
259
// main import to hot update
260
260
const depModules = new Set < string | ModuleNode > ( )
261
+ const devBase = config . base
261
262
for ( const file of deps ) {
262
263
depModules . add (
263
264
isCSSRequest ( file )
@@ -387,10 +388,9 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
387
388
}
388
389
389
390
const cssContent = await getContentWithSourcemap ( css )
390
- const devBase = config . base
391
391
const code = [
392
392
`import { updateStyle as __vite__updateStyle, removeStyle as __vite__removeStyle } from ${ JSON . stringify (
393
- path . posix . join ( devBase , CLIENT_PUBLIC_PATH )
393
+ path . posix . join ( config . base , CLIENT_PUBLIC_PATH )
394
394
) } `,
395
395
`const __vite__id = ${ JSON . stringify ( id ) } ` ,
396
396
`const __vite__css = ${ JSON . stringify ( cssContent ) } ` ,
0 commit comments