@@ -39,6 +39,7 @@ import {
3939 isDataUrl ,
4040 isExternalUrl ,
4141 isObject ,
42+ joinUrlSegments ,
4243 normalizePath ,
4344 parseRequest ,
4445 processSrcSet ,
@@ -211,7 +212,7 @@ export function cssPlugin(config: ResolvedConfig): Plugin {
211212 if ( encodePublicUrlsInCSS ( config ) ) {
212213 return publicFileToBuiltUrl ( url , config )
213214 } else {
214- return config . base + url . slice ( 1 )
215+ return joinUrlSegments ( config . base , url )
215216 }
216217 }
217218 const resolved = await resolveUrl ( url , importer )
@@ -249,7 +250,6 @@ export function cssPlugin(config: ResolvedConfig): Plugin {
249250 // server only logic for handling CSS @import dependency hmr
250251 const { moduleGraph } = server
251252 const thisModule = moduleGraph . getModuleById ( id )
252- const devBase = config . base
253253 if ( thisModule ) {
254254 // CSS modules cannot self-accept since it exports values
255255 const isSelfAccepting =
@@ -258,6 +258,7 @@ export function cssPlugin(config: ResolvedConfig): Plugin {
258258 // record deps in the module graph so edits to @import css can trigger
259259 // main import to hot update
260260 const depModules = new Set < string | ModuleNode > ( )
261+ const devBase = config . base
261262 for ( const file of deps ) {
262263 depModules . add (
263264 isCSSRequest ( file )
@@ -387,10 +388,9 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
387388 }
388389
389390 const cssContent = await getContentWithSourcemap ( css )
390- const devBase = config . base
391391 const code = [
392392 `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 )
394394 ) } `,
395395 `const __vite__id = ${ JSON . stringify ( id ) } ` ,
396396 `const __vite__css = ${ JSON . stringify ( cssContent ) } ` ,
0 commit comments