11import fs from 'node:fs'
22import path from 'node:path'
33
4- import { build } from 'vite'
4+ import { createBuilder } from 'vite'
55import type { Plugin } from 'vite'
66import { afterEach , beforeEach , describe , expect , it , vi } from 'vitest'
77
@@ -147,7 +147,7 @@ describe('src/multi-env', () => {
147147
148148 expect ( fs . existsSync ( mockHtmlPath ) ) . toBe ( false )
149149
150- await build ( {
150+ const builder = await createBuilder ( {
151151 configFile : false ,
152152 root : mockHtmlRoot ,
153153 build : {
@@ -158,6 +158,7 @@ describe('src/multi-env', () => {
158158 plugins : electron ( [ ] ) ,
159159 logLevel : 'silent' ,
160160 } )
161+ await builder . buildApp ( )
161162
162163 expect ( fs . existsSync ( mockHtmlPath ) ) . toBe ( false )
163164 expect ( fs . existsSync ( mockHtmlDistPath ) ) . toBe ( false )
@@ -202,7 +203,7 @@ describe('src/multi-env', () => {
202203
203204 await resetDirs ( appOutDir , electronOutDir )
204205
205- await build ( {
206+ const builder = await createBuilder ( {
206207 configFile : false ,
207208 root,
208209 build : {
@@ -227,6 +228,7 @@ describe('src/multi-env', () => {
227228 ] ,
228229 logLevel : 'silent' ,
229230 } )
231+ await builder . buildApp ( )
230232
231233 expect ( fs . existsSync ( path . join ( appOutDir , 'index.html' ) ) ) . toBe ( true )
232234 expect ( fs . existsSync ( path . join ( electronOutDir , 'main.js' ) ) ) . toBe ( true )
@@ -247,7 +249,7 @@ describe('src/multi-env', () => {
247249
248250 await resetDirs ( appOutDir , electronOutDir )
249251
250- await build ( {
252+ const builder = await createBuilder ( {
251253 configFile : false ,
252254 root,
253255 build : {
@@ -273,6 +275,7 @@ describe('src/multi-env', () => {
273275 ] ) ,
274276 logLevel : 'silent' ,
275277 } )
278+ await builder . buildApp ( )
276279
277280 const mainCode = fs
278281 . readFileSync ( path . join ( electronOutDir , 'env-status.js' ) , 'utf-8' )
@@ -289,7 +292,7 @@ describe('src/multi-env', () => {
289292
290293 await resetDirs ( appOutDir , electronOutDir )
291294
292- await build ( {
295+ const builder = await createBuilder ( {
293296 configFile : false ,
294297 root,
295298 build : {
@@ -319,6 +322,7 @@ describe('src/multi-env', () => {
319322 ] ) ,
320323 logLevel : 'silent' ,
321324 } )
325+ await builder . buildApp ( )
322326
323327 const mainCode = fs
324328 . readFileSync ( path . join ( electronOutDir , 'env-main.js' ) , 'utf-8' )
@@ -336,7 +340,7 @@ describe('src/multi-env', () => {
336340
337341 await resetDirs ( appOutDir , mainOutDir , preloadOutDir )
338342
339- await build ( {
343+ const builder = await createBuilder ( {
340344 configFile : false ,
341345 root,
342346 build : {
@@ -377,6 +381,7 @@ describe('src/multi-env', () => {
377381 ] ) ,
378382 logLevel : 'silent' ,
379383 } )
384+ await builder . buildApp ( )
380385
381386 const mainCode = fs
382387 . readFileSync ( path . join ( mainOutDir , 'env-main.js' ) , 'utf-8' )
@@ -416,7 +421,7 @@ describe('src/multi-env', () => {
416421
417422 await resetDirs ( appOutDir , mainOutDir , preloadOutDir )
418423
419- await build ( {
424+ const builder = await createBuilder ( {
420425 configFile : false ,
421426 root,
422427 build : {
@@ -450,6 +455,7 @@ describe('src/multi-env', () => {
450455 ] ) ,
451456 logLevel : 'silent' ,
452457 } )
458+ await builder . buildApp ( )
453459
454460 const mainCode = fs
455461 . readFileSync ( path . join ( mainOutDir , 'env-main.js' ) , 'utf-8' )
@@ -476,7 +482,7 @@ describe('src/multi-env', () => {
476482
477483 await resetDirs ( appOutDir , mainOutDir , preloadOutDir , logsDir )
478484
479- await build ( {
485+ const builder = await createBuilder ( {
480486 configFile : false ,
481487 root,
482488 build : {
@@ -510,6 +516,7 @@ describe('src/multi-env', () => {
510516 ] ) ,
511517 logLevel : 'silent' ,
512518 } )
519+ await builder . buildApp ( )
513520
514521 const mainCode = fs
515522 . readFileSync ( path . join ( mainOutDir , 'env-main.js' ) , 'utf-8' )
@@ -555,7 +562,7 @@ describe('src/multi-env', () => {
555562
556563 await resetDirs ( appOutDir , electronOutDir )
557564
558- await build ( {
565+ const builder = await createBuilder ( {
559566 configFile : false ,
560567 root,
561568 build : {
@@ -609,6 +616,7 @@ describe('src/multi-env', () => {
609616 ] ) ,
610617 logLevel : 'silent' ,
611618 } )
619+ await builder . buildApp ( )
612620
613621 const mainCode = fs
614622 . readFileSync ( path . join ( electronOutDir , 'env-main.js' ) , 'utf-8' )
0 commit comments