diff --git a/apps/trading/project.json b/apps/trading/project.json index d4005c7b4..64e166721 100644 --- a/apps/trading/project.json +++ b/apps/trading/project.json @@ -32,7 +32,7 @@ } }, "export": { - "executor": "@nrwl/next:export", + "executor": "./tools/executors/next:export", "options": { "buildTarget": "trading:build:production" } diff --git a/tools/executors/next/executor.json b/tools/executors/next/executor.json index cd82d63bd..bf071e4b4 100644 --- a/tools/executors/next/executor.json +++ b/tools/executors/next/executor.json @@ -8,7 +8,12 @@ "build": { "implementation": "./build/impl", "schema": "./build/schema.json", - "description": "Starts a next server with an optional explicit environment." + "description": "Builds a next app with an optional explicit environment." + }, + "export": { + "implementation": "./export/impl", + "schema": "./serve/schema.json", + "description": "Exports a next app with an optional explicit environment." } } } diff --git a/tools/executors/next/export/impl.ts b/tools/executors/next/export/impl.ts new file mode 100644 index 000000000..302aa2618 --- /dev/null +++ b/tools/executors/next/export/impl.ts @@ -0,0 +1,22 @@ +import type { ExecutorContext } from '@nrwl/devkit'; +import setup from '../../../utils/setup-environment'; +import nextExportExecutor from '@nrwl/next/src/executors/export/export.impl'; +import { NextExportBuilderOptions } from '@nrwl/next/src/utils/types'; + +type Schema = NextExportBuilderOptions & { + env: string; +}; + +export default async function exportWithEnv( + options: Schema, + context: ExecutorContext +) { + const { env, ...nextOptions } = options; + await setup(env, context, 'tools/executors/next/export'); + + try { + return await nextExportExecutor(nextOptions, context); + } catch (err) { + console.error(err); + } +} diff --git a/tools/executors/next/export/schema.json b/tools/executors/next/export/schema.json new file mode 100644 index 000000000..a91d1ae55 --- /dev/null +++ b/tools/executors/next/export/schema.json @@ -0,0 +1,18 @@ +{ + "cli": "nx", + "id": "export", + "description": "Exports a next app app using @nrwl/next:export with an optional explicit environment", + "type": "object", + "properties": { + "env": { + "type": "string", + "description": "Target environment to run the application in. This assumes an .env file present in the project's root in the following format: .env.{envName}" + }, + "buildLibsFromSource": { + "type": "boolean", + "description": "Read buildable libraries from source instead of building them separately.", + "default": true + } + }, + "required": ["root", "outputPath"] +} diff --git a/tools/executors/next/tsconfig.json b/tools/executors/next/tsconfig.json index 1cfd7884b..badfe46e0 100644 --- a/tools/executors/next/tsconfig.json +++ b/tools/executors/next/tsconfig.json @@ -8,6 +8,6 @@ "sourceMap": false, "inlineSourceMap": true }, - "include": ["build/impl.ts", "serve/impl.ts"], + "include": ["build/impl.ts", "serve/impl.ts", "export/impl.ts"], "exclude": ["node_modules"] }