1- import { containsDotNextDir , getConfig } from "../config" ;
2- import type { ProjectOptions } from "../config" ;
1+ import type { Config } from "../config" ;
32import { buildNextjsApp } from "./build-next-app" ;
43import { buildWorker } from "./build-worker" ;
4+ import { containsDotNextDir } from "../config" ;
55import { cpSync } from "node:fs" ;
66import { join } from "node:path" ;
77import { rm } from "node:fs/promises" ;
@@ -11,25 +11,23 @@ import { rm } from "node:fs/promises";
1111 *
1212 * It saves the output in a `.worker-next` directory
1313 *
14- * @param projectOpts The options for the project
14+ * @param config Build config
1515 */
16- export async function build ( projectOpts : ProjectOptions ) : Promise < void > {
17- if ( ! projectOpts . skipNextBuild ) {
16+ export async function build ( config : Config ) : Promise < void > {
17+ if ( ! config . build . skipNextBuild ) {
1818 // Build the next app
19- await buildNextjsApp ( projectOpts . sourceDir ) ;
19+ await buildNextjsApp ( config . paths . sourceDir ) ;
2020 }
2121
22- if ( ! containsDotNextDir ( projectOpts . sourceDir ) ) {
23- throw new Error ( `.next folder not found in ${ projectOpts . sourceDir } ` ) ;
22+ if ( ! containsDotNextDir ( config . paths . sourceDir ) ) {
23+ throw new Error ( `.next folder not found in ${ config . paths . sourceDir } ` ) ;
2424 }
2525
2626 // Clean the output directory
27- await cleanDirectory ( projectOpts . outputDir ) ;
27+ await cleanDirectory ( config . paths . outputDir ) ;
2828
2929 // Copy the .next directory to the output directory so it can be mutated.
30- cpSync ( join ( projectOpts . sourceDir , ".next" ) , join ( projectOpts . outputDir , ".next" ) , { recursive : true } ) ;
31-
32- const config = getConfig ( projectOpts ) ;
30+ cpSync ( join ( config . paths . sourceDir , ".next" ) , join ( config . paths . outputDir , ".next" ) , { recursive : true } ) ;
3331
3432 await buildWorker ( config ) ;
3533}
0 commit comments