mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 15:15:19 +00:00
fix(vite, nuxt): resolve relative to srcDir
rather than rootDir
(#6546)
This commit is contained in:
parent
b0bf25cf51
commit
70b024fbaa
@ -146,7 +146,7 @@ export default defineNuxtModule<ComponentsOptions>({
|
||||
if (!['add', 'unlink'].includes(event)) {
|
||||
return
|
||||
}
|
||||
const fPath = resolve(nuxt.options.rootDir, path)
|
||||
const fPath = resolve(nuxt.options.srcDir, path)
|
||||
if (componentDirs.find(dir => fPath.startsWith(dir.path))) {
|
||||
await nuxt.callHook('builder:generateApp')
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ export async function buildClient (ctx: ViteBuildContext) {
|
||||
vuePlugin(ctx.config.vue),
|
||||
viteJsxPlugin(),
|
||||
devStyleSSRPlugin({
|
||||
rootDir: ctx.nuxt.options.rootDir,
|
||||
srcDir: ctx.nuxt.options.srcDir,
|
||||
buildAssetsURL: joinURL(ctx.nuxt.options.app.baseURL, ctx.nuxt.options.app.buildAssetsDir)
|
||||
}),
|
||||
ctx.nuxt.options.experimental.viteNode
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { resolve } from 'pathe'
|
||||
import type { Plugin } from 'vite'
|
||||
|
||||
export function cacheDirPlugin (rootDir, name: string) {
|
||||
export function cacheDirPlugin (rootDir: string, name: string) {
|
||||
const optimizeCacheDir = resolve(rootDir, 'node_modules/.cache/vite', name)
|
||||
return <Plugin> {
|
||||
name: 'nuxt:cache-dir',
|
||||
|
@ -3,7 +3,7 @@ import { Plugin } from 'vite'
|
||||
import { isCSS } from '../utils'
|
||||
|
||||
export interface DevStyleSSRPluginOptions {
|
||||
rootDir: string
|
||||
srcDir: string
|
||||
buildAssetsURL: string
|
||||
}
|
||||
|
||||
@ -18,8 +18,8 @@ export function devStyleSSRPlugin (options: DevStyleSSRPluginOptions): Plugin {
|
||||
}
|
||||
|
||||
let moduleId = id
|
||||
if (moduleId.startsWith(options.rootDir)) {
|
||||
moduleId = moduleId.slice(options.rootDir.length)
|
||||
if (moduleId.startsWith(options.srcDir)) {
|
||||
moduleId = moduleId.slice(options.srcDir.length)
|
||||
}
|
||||
|
||||
// When dev `<style>` is injected, remove the `<link>` styles from manifest
|
||||
|
@ -7,7 +7,7 @@ import { getViteNodeOptions } from './vite-node-shared.mjs'
|
||||
const viteNodeOptions = getViteNodeOptions()
|
||||
|
||||
const runner = new ViteNodeRunner({
|
||||
root: viteNodeOptions.rootDir,
|
||||
root: viteNodeOptions.root, // Equals to Nuxt `srcDir`
|
||||
base: viteNodeOptions.base,
|
||||
async fetchModule (id) {
|
||||
return await $fetch('/module/' + encodeURI(id), {
|
||||
|
@ -143,7 +143,7 @@ export async function initViteNodeServer (ctx: ViteBuildContext) {
|
||||
// Serialize and pass vite-node runtime options
|
||||
const viteNodeServerOptions = {
|
||||
baseURL: `${protocol}://${host}:${port}/__nuxt_vite_node__`,
|
||||
rootDir: ctx.nuxt.options.rootDir,
|
||||
root: ctx.nuxt.options.srcDir,
|
||||
entryPath,
|
||||
base: ctx.ssrServer.config.base || '/_nuxt/'
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user