From 2f4cdd90c376e861cdd27be4c86dafdf03e65e57 Mon Sep 17 00:00:00 2001 From: Soybean Date: Fri, 13 Oct 2023 18:13:53 +0800 Subject: [PATCH] fix(projects): fix plugin enable in serve --- package.json | 4 ++-- packages/vue/src/context/index.ts | 2 -- packages/vue/src/context/transform.ts | 2 +- packages/vue/src/unplugin.ts | 5 ++++- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 06b6d4f..3677813 100644 --- a/package.json +++ b/package.json @@ -20,10 +20,10 @@ "build": "pnpm -r --filter='./packages/*' run build", "stub": "pnpm -r --parallel --filter='./packages/*' run stub", "lint": "eslint . --fix", - "format": "soy prettier-format", + "format": "soy prettier-write", "commit": "soy git-commit", "cleanup": "soy cleanup", - "ncu": "soy ncu", + "update-pkg": "soy ncu", "publish-pkg": "pnpm -r publish --access public", "release": "pnpm soy release && pnpm build && pnpm publish-pkg", "prepare": "pnpm -r run stub" diff --git a/packages/vue/src/context/index.ts b/packages/vue/src/context/index.ts index 90300ef..4672ecb 100644 --- a/packages/vue/src/context/index.ts +++ b/packages/vue/src/context/index.ts @@ -23,8 +23,6 @@ export default class ElegantVueRouter { genTransformFile(this.options); this.generate(); - - this.setupFSWatcher(); } scanPages() { diff --git a/packages/vue/src/context/transform.ts b/packages/vue/src/context/transform.ts index 34e2dbc..982a45e 100644 --- a/packages/vue/src/context/transform.ts +++ b/packages/vue/src/context/transform.ts @@ -84,7 +84,7 @@ export async function genTransformFile(options: ElegantVueRouterOption) { const transformPath = path.posix.join(options.cwd, options.transformDir); - ensureFile(transformPath); + await ensureFile(transformPath); await writeFile(transformPath, code); } diff --git a/packages/vue/src/unplugin.ts b/packages/vue/src/unplugin.ts index 8e09b23..c978aa9 100644 --- a/packages/vue/src/unplugin.ts +++ b/packages/vue/src/unplugin.ts @@ -10,8 +10,11 @@ export default createUnplugin | undefined>((opti return { name: '@elegant-router/vue', enforce: 'pre', - apply: 'serve', vite: { + apply: 'serve', + configResolved() { + ctx.setupFSWatcher(); + }, configureServer(server) { ctx.setViteServer(server); }