refactor: redesign module system

This commit is contained in:
Anthony Fu committed 2021-01-22 18:05:58 +08:00
1 parent 7ba2102b96
commit 4c51428587
8 files changed
+29 -20

No files matched your search

+3 -11
View File
@@ -1,22 +1,14 @@
import './styles/main.postcss'
// import routes generated by Voie
import routes from 'vite-plugin-pages/client'
// progress bar
import NProgress from 'nprogress'
import { ViteSSG } from 'vite-ssg'
import installPlugins from './plugins'
import App from './App.vue'
// https://github.com/antfu/vite-ssg
export const createApp = ViteSSG(
App,
{ routes },
({ app, router, isClient }) => {
installPlugins(app)
if (isClient) {
router.beforeEach(() => { NProgress.start() })
router.afterEach(() => { NProgress.done() })
}
(ctx) => {
// install all modules under `modules/`
Object.values(import.meta.globEager('./modules/*.ts')).map(i => i.install?.(ctx))
},
)