build(ui-templates): directly copy templates on build (#27430)

This commit is contained in:
Daniel Roe 2024-06-03 21:15:54 +01:00 committed by GitHub
parent b788170018
commit b6d797591d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 16 additions and 6 deletions

6
packages/nuxt/.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
src/app/components/error-404.vue
src/app/components/error-500.vue
src/app/components/error-dev.vue
src/app/components/welcome.vue
src/core/runtime/nitro/error-500.ts
src/core/runtime/nitro/error-dev.ts

View File

@ -1 +0,0 @@
../../../../ui-templates/dist/templates/error-404.vue

View File

@ -1 +0,0 @@
../../../../ui-templates/dist/templates/error-500.vue

View File

@ -1 +0,0 @@
../../../../ui-templates/dist/templates/error-dev.vue

View File

@ -1 +0,0 @@
../../../../ui-templates/dist/templates/welcome.vue

View File

@ -1 +0,0 @@
../../../../../ui-templates/dist/templates/error-500.ts

View File

@ -1 +0,0 @@
../../../../../ui-templates/dist/templates/error-dev.ts

View File

@ -1,5 +1,6 @@
import { fileURLToPath } from 'node:url' import { fileURLToPath } from 'node:url'
import { readFileSync, rmdirSync, unlinkSync, writeFileSync } from 'node:fs' import { readFileSync, rmdirSync, unlinkSync, writeFileSync } from 'node:fs'
import { copyFile } from 'node:fs/promises'
import { basename, dirname, join, resolve } from 'pathe' import { basename, dirname, join, resolve } from 'pathe'
import type { Plugin } from 'vite' import type { Plugin } from 'vite'
// @ts-expect-error https://github.com/GoogleChromeLabs/critters/pull/151 // @ts-expect-error https://github.com/GoogleChromeLabs/critters/pull/151
@ -167,6 +168,15 @@ export const RenderPlugin = () => {
unlinkSync(fileName) unlinkSync(fileName)
rmdirSync(dirname(fileName)) rmdirSync(dirname(fileName))
} }
// we manually copy files across rather than using symbolic links for better windows support
const nuxtRoot = r('../nuxt')
for (const file of ['error-404.vue', 'error-500.vue', 'error-dev.vue', 'welcome.vue']) {
await copyFile(r(`dist/templates/${file}`), join(nuxtRoot, 'src/app/components', file))
}
for (const file of ['error-500.ts', 'error-dev.ts']) {
await copyFile(r(`dist/templates/${file}`), join(nuxtRoot, 'src/core/runtime/nitro', file))
}
}, },
} }
} }