feat(schema): split dev/prod build directories (#28594)

This commit is contained in:
Daniel Roe 2024-08-19 17:03:11 +01:00 committed by GitHub
parent 0c9ba32c1e
commit 3ec103b1d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 23 additions and 8 deletions

View File

@ -175,7 +175,29 @@ export default defineUntypedSchema({
* ```
*/
buildDir: {
$resolve: async (val: string | undefined, get): Promise<string> => resolve(await get('rootDir') as string, val || '.nuxt'),
$resolve: async (val: string | undefined, get): Promise<string> => {
const rootDir = await get('rootDir') as string
if (val) {
return resolve(rootDir, val)
}
const defaultBuildDir = resolve(rootDir, '.nuxt')
const isDev = await get('dev') as boolean
if (isDev) {
return defaultBuildDir
}
// TODO: nuxi CLI should ensure .nuxt dir exists
if (!existsSync(defaultBuildDir)) {
// This is to ensure that types continue to work for CI builds
return defaultBuildDir
}
// TODO: handle build caching + using buildId in directory
return resolve(rootDir, 'node_modules/.cache/nuxt/builds', 'production')
},
},
/**

View File

@ -9,7 +9,6 @@ export default defineNuxtConfig({
future: {
typescriptBundlerResolution: process.env.MODULE_RESOLUTION === 'bundler',
},
buildDir: process.env.NITRO_BUILD_DIR,
builder: process.env.TEST_BUILDER as 'webpack' | 'vite' ?? 'vite',
theme: './extends/bar',
extends: [

View File

@ -31,7 +31,6 @@ export default defineNuxtConfig({
include: ['keepalive-in-config', 'not-keepalive-in-nuxtpage'],
},
},
buildDir: process.env.NITRO_BUILD_DIR,
builder: process.env.TEST_BUILDER as 'webpack' | 'vite' ?? 'vite',
appId: 'nuxt-app-basic',
build: {
@ -68,7 +67,6 @@ export default defineNuxtConfig({
'/hydration/spa-redirection/**': { ssr: false },
'/no-scripts': { experimentalNoScripts: true },
},
output: { dir: process.env.NITRO_OUTPUT_DIR },
prerender: {
routes: [
'/random/a',

View File

@ -23,8 +23,6 @@ if (process.env.TEST_ENV !== 'built' && !isWindows) {
setupTimeout: (isWindows ? 360 : 120) * 1000,
nuxtConfig: {
builder: isWebpack ? 'webpack' : 'vite',
buildDir: process.env.NITRO_BUILD_DIR,
nitro: { output: { dir: process.env.NITRO_OUTPUT_DIR } },
},
})

View File

@ -14,8 +14,6 @@ await setup({
setupTimeout: (isWindows ? 360 : 120) * 1000,
nuxtConfig: {
builder: isWebpack ? 'webpack' : 'vite',
buildDir: process.env.NITRO_BUILD_DIR,
nitro: { output: { dir: process.env.NITRO_OUTPUT_DIR } },
},
})