-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
203 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,8 @@ | |
"nx", | ||
"typescript", | ||
"@nx/cypress", | ||
"@nx/playwright" | ||
"@nx/playwright", | ||
"@nx/jest" | ||
] | ||
} | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
title: Nuxt build executor examples | ||
description: This page contains examples for the @nx/nuxt:build executor. | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
title: Nuxt serve executor examples | ||
description: This page contains examples for the @nx/nuxt:serve executor. | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,14 @@ | ||
{ | ||
"executors": {} | ||
"executors": { | ||
"build": { | ||
"implementation": "./src/executors/build/build.impl", | ||
"schema": "./src/executors/build/schema.json", | ||
"description": "Build with Nuxt." | ||
}, | ||
"serve": { | ||
"implementation": "./src/executors/serve/serve.impl", | ||
"schema": "./src/executors/serve/schema.json", | ||
"description": "Serve with Nuxt." | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { ExecutorContext } from '@nx/devkit'; | ||
import { NuxtBuildExecutorOptions } from './schema'; | ||
|
||
// Required because dep is ESM package. Changing moduleResolution to NodeNext causes other issues unfortunately. | ||
export function loadNuxiDynamicImport() { | ||
return Function('return import("nuxi")')() as Promise<typeof import('nuxi')>; | ||
} | ||
|
||
export async function* nuxtBuildExecutor( | ||
options: NuxtBuildExecutorOptions, | ||
context: ExecutorContext | ||
) { | ||
const projectRoot = | ||
context.projectsConfigurations.projects[context.projectName].root; | ||
const { runCommand } = await loadNuxiDynamicImport(); | ||
try { | ||
await runCommand('build', [projectRoot], { | ||
overrides: { | ||
typescript: { | ||
builder: 'shared', | ||
}, | ||
imports: { | ||
autoImport: false, | ||
}, | ||
}, | ||
}); | ||
return { success: true }; | ||
} catch (e) { | ||
return { success: false, error: e }; | ||
} | ||
} | ||
|
||
export default nuxtBuildExecutor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { convertNxExecutor } from '@nx/devkit'; | ||
import nuxtBuildExecutor from './build.impl'; | ||
|
||
export default convertNxExecutor(nuxtBuildExecutor); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export interface NuxtBuildExecutorOptions { | ||
rootDir: string; | ||
prerender?: boolean; | ||
dotenv?: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"version": 2, | ||
"outputCapture": "direct-nodejs", | ||
"title": "Nuxt Prod Builder", | ||
"cli": "nx", | ||
"description": "Builds a Nuxt application for production.", | ||
"type": "object", | ||
"presets": [ | ||
{ | ||
"name": "Default minimum setup", | ||
"keys": [] | ||
} | ||
], | ||
"properties": { | ||
"rootDir": { | ||
"type": "string", | ||
"description": "The root directory of the application to bundle.", | ||
"x-completion-type": "directory", | ||
"x-priority": "important", | ||
"default": "." | ||
}, | ||
"prerender": { | ||
"description": "Pre-render every route of your application. (note: This is an experimental flag. The behavior might be changed.)", | ||
"type": "boolean", | ||
"default": false | ||
}, | ||
"dotenv": { | ||
"description": "Point to another .env file to load, relative to the root directory.", | ||
"type": "string", | ||
"default": "." | ||
} | ||
}, | ||
"definitions": {}, | ||
"required": [], | ||
"examplesFile": "../../../docs/build-examples.md" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { convertNxExecutor } from '@nx/devkit'; | ||
import nuxtServeExecutor from './serve.impl'; | ||
|
||
export default convertNxExecutor(nuxtServeExecutor); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface NuxtServeExecutorOptions { | ||
rootDir: string; | ||
dotenv?: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"version": 2, | ||
"outputCapture": "direct-nodejs", | ||
"title": "Nuxt Server", | ||
"cli": "nx", | ||
"description": "Serves a Nuxt application for development.", | ||
"type": "object", | ||
"presets": [ | ||
{ | ||
"name": "Default minimum setup", | ||
"keys": [] | ||
} | ||
], | ||
"properties": { | ||
"host": { | ||
"type": "string", | ||
"description": "Dev server listening host.", | ||
"default": "" | ||
}, | ||
"port": { | ||
"type": "number", | ||
"description": "Dev server listening port", | ||
"default": 3000 | ||
} | ||
}, | ||
"definitions": {}, | ||
"required": [], | ||
"examplesFile": "../../../docs/serve-examples.md" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { ExecutorContext } from '@nx/devkit'; | ||
import { NuxtServeExecutorOptions } from './schema'; | ||
import { createAsyncIterable } from '@nx/devkit/src/utils/async-iterable'; | ||
|
||
// Required because dep is ESM package. Changing moduleResolution to NodeNext causes other issues unfortunately. | ||
export function loadNuxiDynamicImport() { | ||
return Function('return import("nuxi")')() as Promise<typeof import('nuxi')>; | ||
} | ||
|
||
export async function* nuxtServeExecutor( | ||
options: NuxtServeExecutorOptions, | ||
context: ExecutorContext | ||
) { | ||
const projectRoot = | ||
context.projectsConfigurations.projects[context.projectName].root; | ||
yield* createAsyncIterable<{ success: boolean }>(async ({ next, error }) => { | ||
try { | ||
const { runCommand } = await loadNuxiDynamicImport(); | ||
await runCommand('dev', [projectRoot]); | ||
next({ | ||
success: true, | ||
}); | ||
} catch (err) { | ||
error(new Error(`Nuxt app exited with message ${err.message}`)); | ||
} | ||
}); | ||
} | ||
|
||
export default nuxtServeExecutor; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.