File tree 2 files changed +10
-7
lines changed
packages/vite/src/node/plugins
2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -268,7 +268,11 @@ export async function fileToUrl(
268
268
}
269
269
}
270
270
271
- function fileToDevUrl ( id : string , config : ResolvedConfig ) {
271
+ export function fileToDevUrl (
272
+ id : string ,
273
+ config : ResolvedConfig ,
274
+ skipBase = false ,
275
+ ) : string {
272
276
let rtn : string
273
277
if ( checkPublicFile ( id , config ) ) {
274
278
// in public dir during dev, keep the url as-is
@@ -281,6 +285,9 @@ function fileToDevUrl(id: string, config: ResolvedConfig) {
281
285
// (this is special handled by the serve static middleware
282
286
rtn = path . posix . join ( FS_PREFIX , id )
283
287
}
288
+ if ( skipBase ) {
289
+ return rtn
290
+ }
284
291
const base = joinUrlSegments ( config . server ?. origin ?? '' , config . decodedBase )
285
292
return joinUrlSegments ( base , removeLeadingSlash ( rtn ) )
286
293
}
Original file line number Diff line number Diff line change @@ -65,7 +65,6 @@ import {
65
65
removeDirectQuery ,
66
66
removeUrlQuery ,
67
67
requireResolveFromRootWithFallback ,
68
- stripBase ,
69
68
stripBomTag ,
70
69
urlRE ,
71
70
} from '../utils'
@@ -75,6 +74,7 @@ import type { TransformPluginContext } from '../server/pluginContainer'
75
74
import { addToHTMLProxyTransformResult } from './html'
76
75
import {
77
76
assetUrlRE ,
77
+ fileToDevUrl ,
78
78
fileToUrl ,
79
79
generatedAssets ,
80
80
publicAssetUrlCache ,
@@ -996,16 +996,12 @@ export function cssAnalysisPlugin(config: ResolvedConfig): Plugin {
996
996
// record deps in the module graph so edits to @import css can trigger
997
997
// main import to hot update
998
998
const depModules = new Set < string | ModuleNode > ( )
999
- const devBase = config . base
1000
999
for ( const file of pluginImports ) {
1001
1000
depModules . add (
1002
1001
isCSSRequest ( file )
1003
1002
? moduleGraph . createFileOnlyEntry ( file )
1004
1003
: await moduleGraph . ensureEntryFromUrl (
1005
- stripBase (
1006
- await fileToUrl ( file , config , this ) ,
1007
- ( config . server ?. origin ?? '' ) + devBase ,
1008
- ) ,
1004
+ fileToDevUrl ( file , config , /* skipBase */ true ) ,
1009
1005
ssr ,
1010
1006
) ,
1011
1007
)
You can’t perform that action at this time.
0 commit comments