File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import { devServer } from "./plugins/dev_server.ts";
1212import { buildIdPlugin } from "./plugins/build_id.ts" ;
1313import { clientSnapshot } from "./plugins/client_snapshot.ts" ;
1414import { serverSnapshot } from "./plugins/server_snapshot.ts" ;
15+ import { fixWindowsPaths } from "./plugins/fix_windows.ts" ;
1516
1617export function fresh ( config ?: FreshViteConfig ) : Plugin [ ] {
1718 const fConfig : ResolvedFreshViteConfig = {
@@ -110,6 +111,7 @@ export function fresh(config?: FreshViteConfig): Plugin[] {
110111 "topLevelAwait" ,
111112 ] ,
112113 } ) ,
114+ fixWindowsPaths ( ) ,
113115 deno ( ) ,
114116 ] ;
115117}
Original file line number Diff line number Diff line change 1+ import type { Plugin } from "vite" ;
2+
3+ // Vite by default uses `C:/` style paths on windows. When you return
4+ // `C:\\` paths you may end up with duplicated modules across chunks...
5+ export function fixWindowsPaths ( ) : Plugin {
6+ return {
7+ name : "fresh:fix-windows" ,
8+ enforce : "pre" ,
9+ async resolveId ( id , importer , options ) {
10+ if ( Deno . build . os !== "windows" ) return ;
11+
12+ const resolved = await this . resolve ( id , importer , options ) ;
13+
14+ if ( resolved && / ^ [ \w ] + : \\ / . test ( resolved . id ) ) {
15+ resolved . id = resolved . id . replaceAll ( / [ \\ / ] + / g, "/" ) ;
16+ return resolved ;
17+ }
18+ } ,
19+ } ;
20+ }
You can’t perform that action at this time.
0 commit comments