mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-13 09:33:54 +00:00
refactor: createApp
This commit is contained in:
parent
e6a5037aa2
commit
5b2f0fa191
@ -14,7 +14,7 @@ export interface NuxtApp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Scan project structure
|
// Scan project structure
|
||||||
export async function resolveApp (builder: Builder, options: Partial<NuxtApp> = {}): Promise<NuxtApp> {
|
export async function createApp (builder: Builder, options: Partial<NuxtApp> = {}): Promise<NuxtApp> {
|
||||||
const { nuxt } = builder
|
const { nuxt } = builder
|
||||||
|
|
||||||
// Create base app object
|
// Create base app object
|
||||||
|
@ -10,7 +10,7 @@ import {
|
|||||||
NuxtTemplate
|
NuxtTemplate
|
||||||
} from './template'
|
} from './template'
|
||||||
import { createWatcher } from './watch'
|
import { createWatcher } from './watch'
|
||||||
import { resolveApp, NuxtApp } from './app'
|
import { createApp, NuxtApp } from './app'
|
||||||
import Ignore from './ignore'
|
import Ignore from './ignore'
|
||||||
|
|
||||||
export class Builder {
|
export class Builder {
|
||||||
@ -56,8 +56,8 @@ function watch (builder: Builder) {
|
|||||||
nuxtAppWatcher.watchAll(debounce(() => compileTemplates(builder.templates, nuxt.options.buildDir), 100))
|
nuxtAppWatcher.watchAll(debounce(() => compileTemplates(builder.templates, nuxt.options.buildDir), 100))
|
||||||
|
|
||||||
// Watch user app
|
// Watch user app
|
||||||
const appPattern = `${builder.app.srcDir}/**/*.{${nuxt.options.extensions.join(',')}}`
|
const appPattern = `${builder.app.dir}/**/*.{${nuxt.options.extensions.join(',')}}`
|
||||||
const appWatcher = createWatcher(appPattern, { ...options, cwd: builder.app.srcDir }, ignore)
|
const appWatcher = createWatcher(appPattern, { ...options, cwd: builder.app.dir }, ignore)
|
||||||
// appWatcher.debug('srcDir')
|
// appWatcher.debug('srcDir')
|
||||||
const refreshTemplates = debounce(() => generate(builder), 100)
|
const refreshTemplates = debounce(() => generate(builder), 100)
|
||||||
// Watch for App.vue creation
|
// Watch for App.vue creation
|
||||||
@ -70,7 +70,7 @@ export async function generate (builder: Builder) {
|
|||||||
const { nuxt } = builder
|
const { nuxt } = builder
|
||||||
|
|
||||||
await fsExtra.mkdirp(nuxt.options.buildDir)
|
await fsExtra.mkdirp(nuxt.options.buildDir)
|
||||||
builder.app = await resolveApp(builder)
|
builder.app = await createApp(builder)
|
||||||
|
|
||||||
const templatesDir = join(builder.nuxt.options.appDir, '_templates')
|
const templatesDir = join(builder.nuxt.options.appDir, '_templates')
|
||||||
const appTemplates = await scanTemplates(templatesDir, templateData(builder))
|
const appTemplates = await scanTemplates(templatesDir, templateData(builder))
|
||||||
|
Loading…
Reference in New Issue
Block a user