23
23
* });
24
24
* ```
25
25
*/
26
- import path from 'node:path' ;
27
26
import type { VitePlugin } from '../types.js' ;
28
27
29
28
export interface OverrideComponentsOptions {
@@ -55,13 +54,8 @@ const virtualModuleId = 'tutorialkit:override-components';
55
54
const resolvedId = `\0${ virtualModuleId } ` ;
56
55
57
56
export function overrideComponents ( { components, defaultRoutes } : Options ) : VitePlugin {
58
- let root = '' ;
59
-
60
57
return {
61
58
name : 'tutorialkit-override-components-plugin' ,
62
- configResolved ( resolvedConfig ) {
63
- root = resolvedConfig . root ;
64
- } ,
65
59
resolveId ( id ) {
66
60
if ( id === virtualModuleId ) {
67
61
return resolvedId ;
@@ -71,7 +65,7 @@ export function overrideComponents({ components, defaultRoutes }: Options): Vite
71
65
} ,
72
66
async load ( id ) {
73
67
if ( id === resolvedId ) {
74
- const topBar = components ?. TopBar || resolveDefaultTopBar ( defaultRoutes , root ) ;
68
+ const topBar = components ?. TopBar || resolveDefaultTopBar ( defaultRoutes ) ;
75
69
76
70
return `
77
71
export { default as TopBar } from '${ topBar } ';
@@ -83,11 +77,11 @@ export function overrideComponents({ components, defaultRoutes }: Options): Vite
83
77
} ;
84
78
}
85
79
86
- function resolveDefaultTopBar ( defaultRoutes : boolean , root : string ) {
80
+ function resolveDefaultTopBar ( defaultRoutes : boolean ) {
87
81
if ( defaultRoutes ) {
88
82
return '@tutorialkit/astro/default/components/TopBar.astro' ;
89
83
}
90
84
91
85
// default `TopBar` is used from local file when `defaultRoutes` is disabled
92
- return path . resolve ( root , ' src/components/TopBar.astro') ;
86
+ return './ src/components/TopBar.astro';
93
87
}
0 commit comments