refactor(nuxi,schema): move loading template into schema (#22336)

This commit is contained in:
Daniel Roe 2023-07-26 23:07:23 +02:00 committed by GitHub
parent e2c7edd479
commit 9741f267be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 6 deletions

View File

@ -46,7 +46,7 @@ export default defineNuxtCommand({
let currentHandler: RequestListener | undefined
let loadingMessage = 'Nuxt is starting...'
const loadingHandler: RequestListener = async (_req, res) => {
const { loading: loadingTemplate } = await importModule('@nuxt/ui-templates', config.modulesDir)
const loadingTemplate = config.devServer.loadingTemplate ?? await importModule('@nuxt/ui-templates', config.modulesDir).then(r => r.loading)
res.setHeader('Content-Type', 'text/html; charset=UTF-8')
res.statusCode = 503 // Service Unavailable
res.end(loadingTemplate({ loading: loadingMessage }))

View File

@ -56,7 +56,7 @@
"@nuxt/kit": "workspace:../kit",
"@nuxt/schema": "workspace:../schema",
"@nuxt/telemetry": "^2.3.2",
"@nuxt/ui-templates": "^1.2.0",
"@nuxt/ui-templates": "^1.2.1",
"@nuxt/vite-builder": "workspace:../vite",
"@unhead/ssr": "^1.1.32",
"@unhead/vue": "^1.1.32",

View File

@ -49,6 +49,7 @@
"webpack-dev-middleware": "6.1.1"
},
"dependencies": {
"@nuxt/ui-templates": "^1.2.1",
"defu": "^6.1.2",
"hookable": "^5.5.3",
"pathe": "^1.1.1",

View File

@ -1,4 +1,5 @@
import { defineUntypedSchema } from 'untyped'
import { loading as loadingTemplate } from '@nuxt/ui-templates'
export default defineUntypedSchema({
devServer: {
@ -36,5 +37,12 @@ export default defineUntypedSchema({
* dev server with the full URL (for module and internal use).
*/
url: 'http://localhost:3000',
/**
* Template to show a loading screen
*
* @type {(data: { loading?: string }) => string}
*/
loadingTemplate: loadingTemplate
}
})

View File

@ -347,8 +347,8 @@ importers:
specifier: ^2.3.2
version: 2.3.2
'@nuxt/ui-templates':
specifier: ^1.2.0
version: 1.2.0
specifier: ^1.2.1
version: 1.2.1
'@nuxt/vite-builder':
specifier: workspace:*
version: link:../vite
@ -521,6 +521,9 @@ importers:
packages/schema:
dependencies:
'@nuxt/ui-templates':
specifier: ^1.2.1
version: 1.2.1
defu:
specifier: ^6.1.2
version: 6.1.2
@ -2075,8 +2078,8 @@ packages:
rc9: 2.1.1
std-env: 3.3.3
/@nuxt/ui-templates@1.2.0:
resolution: {integrity: sha512-MSZza7dxccNb/p7nuzGF8/m4POaFpHzVhNdR7f4xahOpH7Ja02lFeYR+rHtoHIJC0yym4qriqv0mQ+Qf/R61bQ==}
/@nuxt/ui-templates@1.2.1:
resolution: {integrity: sha512-Nt1nTkPsji/X8z/BCqUgb8uADs+kT0FZboVDwyCdMlCgjEQKrAZUlunKXGywa6ssz4/RohGmvuB1cFre6dSKXQ==}
dev: false
/@nuxtjs/eslint-config-typescript@12.0.0(eslint@8.45.0)(typescript@5.0.4):