mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-21 21:25:11 +00:00
fix(vite): set different cache dirs for client/server (#20276)
This commit is contained in:
parent
53db8125f1
commit
b602b66a8e
@ -10,7 +10,6 @@ import { joinURL, withoutLeadingSlash } from 'ufo'
|
||||
import { defu } from 'defu'
|
||||
import { defineEventHandler } from 'h3'
|
||||
import type { ViteConfig } from '@nuxt/schema'
|
||||
import { cacheDirPlugin } from './plugins/cache-dir'
|
||||
import { chunkErrorPlugin } from './plugins/chunk-error'
|
||||
import type { ViteBuildContext } from './vite'
|
||||
import { devStyleSSRPlugin } from './plugins/dev-ssr-css'
|
||||
@ -51,6 +50,7 @@ export async function buildClient (ctx: ViteBuildContext) {
|
||||
},
|
||||
dedupe: ['vue']
|
||||
},
|
||||
cacheDir: resolve(ctx.nuxt.options.rootDir, 'node_modules/.cache/vite', 'client'),
|
||||
build: {
|
||||
sourcemap: ctx.nuxt.options.sourcemap.client ? ctx.config.build?.sourcemap ?? true : false,
|
||||
manifest: true,
|
||||
@ -60,7 +60,6 @@ export async function buildClient (ctx: ViteBuildContext) {
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
cacheDirPlugin(ctx.nuxt.options.rootDir, 'client'),
|
||||
devStyleSSRPlugin({
|
||||
srcDir: ctx.nuxt.options.srcDir,
|
||||
buildAssetsURL: joinURL(ctx.nuxt.options.app.baseURL, ctx.nuxt.options.app.buildAssetsDir)
|
||||
|
@ -1,13 +0,0 @@
|
||||
import { resolve } from 'pathe'
|
||||
import type { Plugin } from 'vite'
|
||||
|
||||
export function cacheDirPlugin (rootDir: string, name: string) {
|
||||
const optimizeCacheDir = resolve(rootDir, 'node_modules/.cache/vite', name)
|
||||
return <Plugin> {
|
||||
name: 'nuxt:cache-dir',
|
||||
configResolved (resolvedConfig) {
|
||||
// @ts-expect-error
|
||||
resolvedConfig.optimizeCacheDir = optimizeCacheDir
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ import { joinURL, withTrailingSlash, withoutLeadingSlash } from 'ufo'
|
||||
import type { ViteConfig } from '@nuxt/schema'
|
||||
import type { ViteBuildContext } from './vite'
|
||||
import { createViteLogger } from './utils/logger'
|
||||
import { cacheDirPlugin } from './plugins/cache-dir'
|
||||
import { initViteNodeServer } from './vite-node'
|
||||
import { ssrStylesPlugin } from './plugins/ssr-styles'
|
||||
import { pureAnnotationsPlugin } from './plugins/pure-annotations'
|
||||
@ -82,6 +81,7 @@ export async function buildServer (ctx: ViteBuildContext) {
|
||||
/(nuxt|nuxt3)\/(dist|src|app)/
|
||||
]
|
||||
},
|
||||
cacheDir: resolve(ctx.nuxt.options.rootDir, 'node_modules/.cache/vite', 'server'),
|
||||
build: {
|
||||
sourcemap: ctx.nuxt.options.sourcemap.server ? ctx.config.build?.sourcemap ?? true : false,
|
||||
outDir: resolve(ctx.nuxt.options.buildDir, 'dist/server'),
|
||||
@ -110,7 +110,6 @@ export async function buildServer (ctx: ViteBuildContext) {
|
||||
hmr: false
|
||||
},
|
||||
plugins: [
|
||||
cacheDirPlugin(ctx.nuxt.options.rootDir, 'server'),
|
||||
pureAnnotationsPlugin.vite({
|
||||
sourcemap: ctx.nuxt.options.sourcemap.server,
|
||||
functions: ['defineComponent', 'defineAsyncComponent', 'defineNuxtLink', 'createClientOnly', 'defineNuxtPlugin', 'defineNuxtRouteMiddleware', 'defineNuxtComponent', 'useRuntimeConfig']
|
||||
|
Loading…
Reference in New Issue
Block a user