mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-18 01:15:58 +00:00
fix(nuxt3): resolve dist dir by top level module
This commit is contained in:
parent
709c7b1912
commit
91c6ef57e7
@ -1,6 +1,7 @@
|
||||
import { statSync } from 'fs'
|
||||
import { resolve, relative } from 'upath'
|
||||
import { defineNuxtModule, resolveAlias, addVitePlugin, addWebpackPlugin } from '@nuxt/kit'
|
||||
import { distDir } from '../dirs'
|
||||
import { scanComponents } from './scan'
|
||||
import type { Component, ComponentsDir } from './types'
|
||||
import { loaderPlugin } from './loader'
|
||||
@ -66,7 +67,7 @@ export default defineNuxtModule({
|
||||
|
||||
app.templates.push({
|
||||
filename: 'components.mjs',
|
||||
src: resolve(__dirname, 'runtime/components.tmpl.mjs'),
|
||||
src: resolve(distDir, 'pages/runtime/components.tmpl.mjs'),
|
||||
options: { components }
|
||||
})
|
||||
|
||||
|
@ -5,6 +5,7 @@ import pagesModule from '../pages/module'
|
||||
import metaModule from '../meta/module'
|
||||
import componentsModule from '../components/module'
|
||||
import globalImportsModule from '../global-imports/module'
|
||||
import { distDir, pkgDir } from '../dirs'
|
||||
import { initNitro } from './nitro'
|
||||
|
||||
export function createNuxt (options: NuxtOptions): Nuxt {
|
||||
@ -55,11 +56,10 @@ export async function loadNuxt (opts: LoadNuxtOptions): Promise<Nuxt> {
|
||||
const options = loadNuxtConfig(opts)
|
||||
|
||||
// Temp
|
||||
const distDir = resolve(__dirname, '..')
|
||||
options.appDir = options.alias['#app'] = resolve(distDir, 'app')
|
||||
options._majorVersion = 3
|
||||
options.buildModules.push(pagesModule, metaModule, componentsModule, globalImportsModule)
|
||||
options.modulesDir.push(resolve(distDir, '../node_modules'))
|
||||
options.modulesDir.push(resolve(pkgDir, 'node_modules'))
|
||||
|
||||
const nuxt = createNuxt(options)
|
||||
|
||||
|
4
packages/nuxt3/src/dirs.ts
Normal file
4
packages/nuxt3/src/dirs.ts
Normal file
@ -0,0 +1,4 @@
|
||||
import { resolve } from 'upath'
|
||||
|
||||
export const distDir = __dirname
|
||||
export const pkgDir = resolve(distDir, '..')
|
@ -1,5 +1,6 @@
|
||||
import { resolve } from 'upath'
|
||||
import { addPlugin, addTemplate, defineNuxtModule } from '@nuxt/kit'
|
||||
import { distDir } from '../dirs'
|
||||
import type { MetaObject } from './types'
|
||||
|
||||
export default defineNuxtModule({
|
||||
@ -9,7 +10,7 @@ export default defineNuxtModule({
|
||||
viewport: 'width=device-width, initial-scale=1'
|
||||
},
|
||||
setup (options, nuxt) {
|
||||
const runtimeDir = resolve(__dirname, 'runtime')
|
||||
const runtimeDir = resolve(distDir, 'meta/runtime')
|
||||
|
||||
// Transpile @nuxt/meta and @vueuse/head
|
||||
nuxt.options.build.transpile.push(runtimeDir, '@vueuse/head')
|
||||
|
@ -1,13 +1,14 @@
|
||||
import { existsSync } from 'fs'
|
||||
import { defineNuxtModule, addTemplate, addPlugin } from '@nuxt/kit'
|
||||
import { resolve } from 'upath'
|
||||
import { distDir } from '../dirs'
|
||||
import { resolveLayouts, resolvePagesRoutes } from './utils'
|
||||
|
||||
export default defineNuxtModule({
|
||||
name: 'router',
|
||||
setup (_options, nuxt) {
|
||||
const pagesDir = resolve(nuxt.options.srcDir, nuxt.options.dir.pages)
|
||||
const runtimeDir = resolve(__dirname, 'runtime')
|
||||
const runtimeDir = resolve(distDir, 'pages/runtime')
|
||||
|
||||
// Disable module if pages dir do not exists
|
||||
if (!existsSync(pagesDir)) {
|
||||
|
Loading…
Reference in New Issue
Block a user