chore: add custom export executor for next app (#1999)

* chore: add custom export executor for next app

* chore: update tsconfig path for export executor
This commit is contained in:
Matthew Russell 2022-11-08 20:59:49 -06:00 committed by GitHub
parent 71e8235faf
commit 5666b8f8e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 48 additions and 3 deletions

View File

@ -32,7 +32,7 @@
}
},
"export": {
"executor": "@nrwl/next:export",
"executor": "./tools/executors/next:export",
"options": {
"buildTarget": "trading:build:production"
}

View File

@ -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."
}
}
}

View File

@ -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);
}
}

View File

@ -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"]
}

View File

@ -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"]
}