diff --git a/src/types/uni-pages.d.ts b/src/types/uni-pages.d.ts index 1c3a2ee..0925902 100644 --- a/src/types/uni-pages.d.ts +++ b/src/types/uni-pages.d.ts @@ -4,13 +4,7 @@ // Generated by vite-plugin-uni-pages interface NavigateToOptions { - url: "/pages/coupon/index" | - "/pages/about/about" | - "/pages/activity/index" | - "/pages/coupon/order" | - "/pages/coupon/product" | - "/pages/index/index" | - "/pages/login/index"; + url: "/pages/login/index"; } interface RedirectToOptions extends NavigateToOptions {} diff --git a/vite.config.ts b/vite.config.ts index 8b38a38..b97d44d 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -17,6 +17,15 @@ import AutoImport from 'unplugin-auto-import/vite' import { visualizer } from 'rollup-plugin-visualizer' import ViteRestart from 'vite-plugin-restart' +import fs from 'fs' +const pages = fs.readdirSync('./src/pages') +const target = process.argv.slice(2) +const result = pages + .filter((dir) => { + return !target.includes(dir) + }) + .map((ele) => `**/${ele}`) + // https://vitejs.dev/config/ export default ({ command, mode }) => { // console.log(mode === process.env.NODE_ENV) // true @@ -50,7 +59,7 @@ export default ({ command, mode }) => { plugins: [ UniPages({ - exclude: ['**/components/**/**.*'], + exclude: ['**/components/**/**.*', ...result], routeBlockLang: 'json5', // 虽然设了默认值,但是vue文件还是要加上 lang="json5", 这样才能很好地格式化 // homePage 通过 vue 文件的 route-block 的type="home"来设定 // pages 目录为 src/pages,分包目录不能配置在pages目录下