Skip to content

Commit

Permalink
feat(nuxt): load config programmatically
Browse files Browse the repository at this point in the history
  • Loading branch information
mandarini committed Nov 13, 2023
1 parent 23565f1 commit 7806499
Show file tree
Hide file tree
Showing 4 changed files with 281 additions and 171 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"@nestjs/schematics": "^9.1.0",
"@nestjs/swagger": "^6.0.0",
"@nestjs/testing": "^9.0.0",
"@nuxt/kit": "^3.8.0",
"@ngrx/effects": "~16.0.0",
"@ngrx/router-store": "~16.0.0",
"@ngrx/store": "~16.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/nuxt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"dependencies": {
"nuxi": "npm:[email protected]",
"tslib": "^2.3.0",
"@nuxt/kit": "^3.8.0",
"@nx/devkit": "file:../devkit",
"@nx/js": "file:../js",
"@nx/eslint": "file:../eslint",
Expand Down
12 changes: 12 additions & 0 deletions packages/nuxt/src/executors/build/build.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,25 @@ export function loadNuxiDynamicImport() {
return Function('return import("nuxi")')() as Promise<typeof import('nuxi')>;
}

export function loadNuxtKitDynamicImport() {
return Function('return import("@nuxt/kit")')() as Promise<
typeof import('@nuxt/kit')
>;
}

export async function* nuxtBuildExecutor(
options: NuxtBuildExecutorOptions,
context: ExecutorContext
) {
const projectRoot =
context.projectsConfigurations.projects[context.projectName].root;
const { runCommand } = await loadNuxiDynamicImport();
const { loadNuxtConfig } = await loadNuxtKitDynamicImport();
const config = await loadNuxtConfig({
cwd: joinPathFragments(context.root, projectRoot),
});
console.log('config', config);

try {
await runCommand('build', [projectRoot], {
overrides: {
Expand Down
Loading

0 comments on commit 7806499

Please sign in to comment.