1
1
import { join } from 'node:path'
2
2
import { existsSync } from 'node:fs'
3
3
import process from 'node:process'
4
- import { fileURLToPath } from 'node:url'
5
4
import type { Plugin } from 'vite'
6
5
import Icons from 'unplugin-icons/vite'
7
6
import IconsResolver from 'unplugin-icons/resolver'
@@ -18,6 +17,9 @@ import { createVueCompilerFlagsPlugin } from './compilerFlagsVue'
18
17
import { createMonacoTypesLoader } from './monacoTypes'
19
18
import { createVuePlugin } from './vue'
20
19
import { createMonacoWriter } from './monacoWrite'
20
+ import { createLayoutWrapperPlugin } from './layoutWrapper'
21
+ import { createContextInjectionPlugin } from './contextInjection'
22
+ import { createHmrPatchPlugin } from './hmrPatch'
21
23
22
24
export async function ViteSlidevPlugin (
23
25
options : ResolvedSlidevOptions ,
@@ -44,11 +46,12 @@ export async function ViteSlidevPlugin(
44
46
const publicRoots = [ ...themeRoots , ...addonRoots ] . map ( i => join ( i , 'public' ) ) . filter ( existsSync )
45
47
46
48
const plugins = [
49
+ createSlidesLoader ( options , serverOptions ) ,
47
50
createMarkdownPlugin ( options , pluginOptions ) ,
48
-
51
+ createLayoutWrapperPlugin ( options ) ,
52
+ createContextInjectionPlugin ( ) ,
49
53
createVuePlugin ( options , pluginOptions ) ,
50
- createSlidesLoader ( options , pluginOptions , serverOptions ) ,
51
- createMonacoWriter ( options ) ,
54
+ createHmrPatchPlugin ( ) ,
52
55
53
56
Components ( {
54
57
extensions : [ 'vue' , 'md' , 'js' , 'ts' , 'jsx' , 'tsx' ] ,
@@ -78,7 +81,7 @@ export async function ViteSlidevPlugin(
78
81
79
82
Icons ( {
80
83
defaultClass : 'slidev-icon' ,
81
- collectionsNodeResolvePath : fileURLToPath ( import . meta . url ) ,
84
+ collectionsNodeResolvePath : options . cliRoot ,
82
85
...iconsOptions ,
83
86
} ) ,
84
87
@@ -120,6 +123,7 @@ export async function ViteSlidevPlugin(
120
123
121
124
createConfigPlugin ( options ) ,
122
125
createMonacoTypesLoader ( options ) ,
126
+ createMonacoWriter ( options ) ,
123
127
createVueCompilerFlagsPlugin ( options ) ,
124
128
createUnocssPlugin ( options , pluginOptions ) ,
125
129
0 commit comments