@@ -69,12 +69,19 @@ const excludeDeps = [
69
69
const getPlugin = ( opts : QwikVitePluginOptions | undefined ) =>
70
70
( qwikVite ( opts ) as any ) [ 0 ] as QwikVitePlugin ;
71
71
72
+ // undefined for Vite 5 - 6, an object for Vite 7
73
+ const configHookPluginContext = undefined as any ;
74
+
72
75
test ( 'command: serve, mode: development' , async ( ) => {
73
76
const initOpts = {
74
77
optimizerOptions : mockOptimizerOptions ( ) ,
75
78
} ;
76
79
const plugin = getPlugin ( initOpts ) ;
77
- const c = ( await plugin . config ( { } , { command : 'serve' , mode : 'development' } ) ) ! ;
80
+ const c = ( await plugin . config . call (
81
+ configHookPluginContext ,
82
+ { } ,
83
+ { command : 'serve' , mode : 'development' }
84
+ ) ) ! ;
78
85
const opts = await plugin . api ?. getOptions ( ) ;
79
86
const build = c . build ! ;
80
87
const rollupOptions = build ! . rollupOptions ! ;
@@ -117,7 +124,11 @@ test('command: serve, mode: production', async () => {
117
124
optimizerOptions : mockOptimizerOptions ( ) ,
118
125
} ;
119
126
const plugin = getPlugin ( initOpts ) ;
120
- const c = ( await plugin . config ( { } , { command : 'serve' , mode : 'production' } ) ) ! ;
127
+ const c = ( await plugin . config . call (
128
+ configHookPluginContext ,
129
+ { } ,
130
+ { command : 'serve' , mode : 'production' }
131
+ ) ) ! ;
121
132
const opts = await plugin . api ?. getOptions ( ) ;
122
133
const build = c . build ! ;
123
134
const rollupOptions = build ! . rollupOptions ! ;
@@ -152,7 +163,11 @@ test('command: build, mode: development', async () => {
152
163
optimizerOptions : mockOptimizerOptions ( ) ,
153
164
} ;
154
165
const plugin = getPlugin ( initOpts ) ;
155
- const c = ( await plugin . config ( { } , { command : 'build' , mode : 'development' } ) ) ! ;
166
+ const c = ( await plugin . config . call (
167
+ configHookPluginContext ,
168
+ { } ,
169
+ { command : 'build' , mode : 'development' }
170
+ ) ) ! ;
156
171
const opts = await plugin . api ?. getOptions ( ) ;
157
172
const build = c . build ! ;
158
173
const rollupOptions = build ! . rollupOptions ! ;
@@ -199,7 +214,11 @@ test('command: build, mode: production', async () => {
199
214
optimizerOptions : mockOptimizerOptions ( ) ,
200
215
} ;
201
216
const plugin = getPlugin ( initOpts ) ;
202
- const c = ( await plugin . config ( { } , { command : 'build' , mode : 'production' } ) ) ! ;
217
+ const c = ( await plugin . config . call (
218
+ configHookPluginContext ,
219
+ { } ,
220
+ { command : 'build' , mode : 'production' }
221
+ ) ) ! ;
203
222
const opts = await plugin . api ?. getOptions ( ) ;
204
223
const build = c . build ! ;
205
224
const rollupOptions = build ! . rollupOptions ! ;
@@ -244,7 +263,11 @@ test('command: build, --mode production (client)', async () => {
244
263
} ;
245
264
246
265
const plugin = getPlugin ( initOpts ) ;
247
- const c : any = ( await plugin . config ( { } , { command : 'build' , mode : 'production' } ) ) ! ;
266
+ const c : any = ( await plugin . config . call (
267
+ configHookPluginContext ,
268
+ { } ,
269
+ { command : 'build' , mode : 'production' }
270
+ ) ) ! ;
248
271
const opts = await plugin . api ?. getOptions ( ) ;
249
272
const build = c . build ! ;
250
273
const rollupOptions = build ! . rollupOptions ! ;
@@ -262,7 +285,8 @@ test('command: build, --ssr entry.server.tsx', async () => {
262
285
optimizerOptions : mockOptimizerOptions ( ) ,
263
286
} ;
264
287
const plugin = getPlugin ( initOpts ) ;
265
- const c = ( await plugin . config (
288
+ const c = ( await plugin . config . call (
289
+ configHookPluginContext ,
266
290
{ build : { ssr : resolve ( cwd , 'src' , 'entry.server.tsx' ) } } ,
267
291
{ command : 'build' , mode : '' }
268
292
) ) ! ;
@@ -307,7 +331,8 @@ test('command: serve, --mode ssr', async () => {
307
331
} ,
308
332
} ;
309
333
const plugin = getPlugin ( initOpts ) ;
310
- const c : any = ( await plugin . config (
334
+ const c : any = ( await plugin . config . call (
335
+ configHookPluginContext ,
311
336
{ build : { emptyOutDir : true } } ,
312
337
{ command : 'serve' , mode : 'ssr' }
313
338
) ) ! ;
@@ -335,7 +360,8 @@ test('command: serve, --mode ssr with build.assetsDir', async () => {
335
360
} ,
336
361
} ;
337
362
const plugin = getPlugin ( initOpts ) ;
338
- const c : any = ( await plugin . config (
363
+ const c : any = ( await plugin . config . call (
364
+ configHookPluginContext ,
339
365
{ build : { emptyOutDir : true , assetsDir : 'my-assets-dir' } } ,
340
366
{ command : 'serve' , mode : 'ssr' }
341
367
) ) ! ;
@@ -359,7 +385,8 @@ test('should use the dist/ fallback with client target', async () => {
359
385
optimizerOptions : mockOptimizerOptions ( ) ,
360
386
} ;
361
387
const plugin = getPlugin ( initOpts ) ;
362
- const c : any = ( await plugin . config (
388
+ const c : any = ( await plugin . config . call (
389
+ configHookPluginContext ,
363
390
{ build : { assetsDir : 'my-assets-dir/' } } ,
364
391
{ command : 'serve' , mode : 'development' }
365
392
) ) ! ;
@@ -372,7 +399,8 @@ test('should use build.outDir config with client target', async () => {
372
399
optimizerOptions : mockOptimizerOptions ( ) ,
373
400
} ;
374
401
const plugin = getPlugin ( initOpts ) ;
375
- const c : any = ( await plugin . config (
402
+ const c : any = ( await plugin . config . call (
403
+ configHookPluginContext ,
376
404
{ build : { outDir : 'my-dist/' , assetsDir : 'my-assets-dir' } } ,
377
405
{ command : 'serve' , mode : 'development' }
378
406
) ) ! ;
@@ -388,7 +416,8 @@ test('should use build.outDir config when assetsDir is _astro', async () => {
388
416
const plugin = getPlugin ( initOpts ) ;
389
417
390
418
// Astro sets a build.assetsDir of _astro, but we don't want to change that
391
- const c : any = ( await plugin . config (
419
+ const c : any = ( await plugin . config . call (
420
+ configHookPluginContext ,
392
421
{ build : { assetsDir : '_astro' } } ,
393
422
{ command : 'serve' , mode : 'development' }
394
423
) ) ! ;
@@ -401,7 +430,8 @@ test('command: build, --mode lib', async () => {
401
430
optimizerOptions : mockOptimizerOptions ( ) ,
402
431
} ;
403
432
const plugin = getPlugin ( initOpts ) ;
404
- const c : any = ( await plugin . config (
433
+ const c : any = ( await plugin . config . call (
434
+ configHookPluginContext ,
405
435
{
406
436
build : {
407
437
lib : {
@@ -436,7 +466,8 @@ test('command: build, --mode lib with multiple outputs', async () => {
436
466
optimizerOptions : mockOptimizerOptions ( ) ,
437
467
} ;
438
468
const plugin = getPlugin ( initOpts ) ;
439
- const c : any = ( await plugin . config (
469
+ const c : any = ( await plugin . config . call (
470
+ configHookPluginContext ,
440
471
{
441
472
build : {
442
473
lib : {
0 commit comments