feat(core): use dynamic import to resolve mcfly config
This commit is contained in:
parent
b6f2b92881
commit
3b8c6e6d11
1 changed files with 6 additions and 2 deletions
|
@ -3,7 +3,7 @@ import { useStorage } from 'nitropack/runtime'
|
||||||
import { createHooks } from 'hookable'
|
import { createHooks } from 'hookable'
|
||||||
import { consola } from 'consola'
|
import { consola } from 'consola'
|
||||||
import { colorize } from 'consola/utils'
|
import { colorize } from 'consola/utils'
|
||||||
import { loadConfig } from 'c12'
|
import { resolve } from 'pathe'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
hooks as mcflyHooks,
|
hooks as mcflyHooks,
|
||||||
|
@ -28,7 +28,11 @@ export default eventHandler(async (event) => {
|
||||||
const hooks = createHooks()
|
const hooks = createHooks()
|
||||||
Object.keys(mcflyHooks).forEach((hookName) => hooks.addHooks(hookName))
|
Object.keys(mcflyHooks).forEach((hookName) => hooks.addHooks(hookName))
|
||||||
const { path } = event
|
const { path } = event
|
||||||
let { config } = await loadConfig({ name: 'mcfly' })
|
|
||||||
|
// TODO: detect config file type
|
||||||
|
const mcflyConfigPath = resolve('./mcfly.config.mjs')
|
||||||
|
let { default: configFn } = await import(mcflyConfigPath)
|
||||||
|
let config = configFn()
|
||||||
const storage = useStorage()
|
const storage = useStorage()
|
||||||
|
|
||||||
// if not page, don't render
|
// if not page, don't render
|
||||||
|
|
Loading…
Reference in a new issue