From 7a375c3ca336110423c7d9f8bfaae339d8cb05df Mon Sep 17 00:00:00 2001 From: jinmao88 <50581550+jinmao88@users.noreply.github.com> Date: Tue, 26 Dec 2023 17:53:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0vite=E7=89=88?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/admin/package.json | 3 ++- apps/admin/postcss.config.js | 2 +- apps/admin/src/router/routes/index.ts | 10 ++++++---- apps/gf-vben/package.json | 3 ++- apps/gf-vben/postcss.config.js | 2 +- apps/gf-vben/src/router/routes/index.ts | 10 ++++++---- configs/css-preprocess/package.json | 5 +++-- configs/css-preprocess/postcss.js | 2 +- configs/vite/package.json | 7 ++++--- configs/vite/src/index.ts | 2 +- packages/router/src/routes/index.ts | 4 +++- packages/vbenComponents/src/index.ts | 1 - 12 files changed, 30 insertions(+), 21 deletions(-) diff --git a/apps/admin/package.json b/apps/admin/package.json index 2ff2b218..4fac42de 100644 --- a/apps/admin/package.json +++ b/apps/admin/package.json @@ -6,6 +6,7 @@ "url": "git+https://github.com/vbenjs/vue-vben-admin.git", "directory": "apps/ant-app" }, + "type": "module", "author": { "name": "vben", "email": "anncwb@126.com", @@ -63,7 +64,7 @@ "@vue/test-utils": "^2.4.1", "naive-ui": "^2.35.0", "typescript": "^5.2.2", - "vite": "4.5.0", + "vite": "5.0.10", "vue-tsc": "^1.8.20" } } diff --git a/apps/admin/postcss.config.js b/apps/admin/postcss.config.js index db0f61f9..ec7d86ee 100644 --- a/apps/admin/postcss.config.js +++ b/apps/admin/postcss.config.js @@ -1 +1 @@ -module.exports = require('@config/css-preprocess/postcss') +export * from '@config/css-preprocess/postcss.js' diff --git a/apps/admin/src/router/routes/index.ts b/apps/admin/src/router/routes/index.ts index 2fde090c..cd86ac09 100644 --- a/apps/admin/src/router/routes/index.ts +++ b/apps/admin/src/router/routes/index.ts @@ -1,7 +1,9 @@ -import { loadRoutesFromModules } from '@vben/utils'; -import { RouteRecordRaw } from 'vue-router'; +import { loadRoutesFromModules } from '@vben/utils' +import { RouteRecordRaw } from 'vue-router' -const routeModuleRecord = import.meta.globEager('./modules/**/*.ts') as any -const routeModules: RouteRecordRaw[] = loadRoutesFromModules(routeModuleRecord); +const routeModuleRecord = import.meta.glob('./modules/**/*.ts', { + eager: true, +}) as any +const routeModules: RouteRecordRaw[] = loadRoutesFromModules(routeModuleRecord) export const asyncRoutes = [...routeModules] diff --git a/apps/gf-vben/package.json b/apps/gf-vben/package.json index e56455b8..63bb54a0 100644 --- a/apps/gf-vben/package.json +++ b/apps/gf-vben/package.json @@ -22,6 +22,7 @@ "server:gzip": "pnpx http-server dist --cors --gzip -c-1", "type:check": "vue-tsc --noEmit --skipLibCheck" }, + "type": "module", "dependencies": { "@ant-design/icons-vue": "^7.0.1", "@config/vite": "workspace:*", @@ -63,7 +64,7 @@ "@vue/test-utils": "^2.4.1", "naive-ui": "^2.35.0", "typescript": "^5.2.2", - "vite": "4.5.0", + "vite": "5.0.10", "vue-tsc": "^1.8.20" } } diff --git a/apps/gf-vben/postcss.config.js b/apps/gf-vben/postcss.config.js index db0f61f9..ec7d86ee 100644 --- a/apps/gf-vben/postcss.config.js +++ b/apps/gf-vben/postcss.config.js @@ -1 +1 @@ -module.exports = require('@config/css-preprocess/postcss') +export * from '@config/css-preprocess/postcss.js' diff --git a/apps/gf-vben/src/router/routes/index.ts b/apps/gf-vben/src/router/routes/index.ts index 2fde090c..cd86ac09 100644 --- a/apps/gf-vben/src/router/routes/index.ts +++ b/apps/gf-vben/src/router/routes/index.ts @@ -1,7 +1,9 @@ -import { loadRoutesFromModules } from '@vben/utils'; -import { RouteRecordRaw } from 'vue-router'; +import { loadRoutesFromModules } from '@vben/utils' +import { RouteRecordRaw } from 'vue-router' -const routeModuleRecord = import.meta.globEager('./modules/**/*.ts') as any -const routeModules: RouteRecordRaw[] = loadRoutesFromModules(routeModuleRecord); +const routeModuleRecord = import.meta.glob('./modules/**/*.ts', { + eager: true, +}) as any +const routeModules: RouteRecordRaw[] = loadRoutesFromModules(routeModuleRecord) export const asyncRoutes = [...routeModules] diff --git a/configs/css-preprocess/package.json b/configs/css-preprocess/package.json index f6214833..6c4dd639 100644 --- a/configs/css-preprocess/package.json +++ b/configs/css-preprocess/package.json @@ -2,6 +2,7 @@ "name": "@config/css-preprocess", "version": "0.0.1", "private": true, + "type": "module", "files": [ "postcss.js", "tailwind.js", @@ -11,7 +12,7 @@ "clean": "pnpm rimraf node_modules && pnpm rimraf dist && pnpm rimraf .turbo" }, "dependencies": { - "postcss": "^8.4.31", - "postcss-preset-env": "^9.2.0" + "postcss": "^8.4.32", + "postcss-preset-env": "^9.3.0" } } diff --git a/configs/css-preprocess/postcss.js b/configs/css-preprocess/postcss.js index 2bfa4519..137df5ff 100644 --- a/configs/css-preprocess/postcss.js +++ b/configs/css-preprocess/postcss.js @@ -1,4 +1,4 @@ -module.exports = { +export default { plugins: { 'postcss-preset-env': { autoprefixer: {}, diff --git a/configs/vite/package.json b/configs/vite/package.json index 6abb5c37..538af829 100644 --- a/configs/vite/package.json +++ b/configs/vite/package.json @@ -2,12 +2,13 @@ "name": "@config/vite", "version": "0.0.2", "private": true, - "main": "dist/index.cjs", + "main": "dist/index.mjs", "types": "dist/index.d.ts", "scripts": { "clean": "pnpm rimraf node_modules && pnpm rimraf dist && pnpm rimraf .turbo", "prepack": "pnpm unbuild --stub" }, + "type": "module", "dependencies": { "@vben/utils": "workspace:*", "@vitejs/plugin-legacy": "^4.1.1", @@ -23,8 +24,8 @@ "rollup-plugin-visualizer": "^5.9.2", "terser": "^5.22.0", "@config/tsconfig": "workspace:*", - "unocss": "^0.57.1", - "vite": "4.5.0", + "unocss": "^0.58.0", + "vite": "5.0.10", "vite-plugin-compression": "^0.5.1", "vite-plugin-html": "^3.2.0", "vite-plugin-imagemin": "^0.6.1", diff --git a/configs/vite/src/index.ts b/configs/vite/src/index.ts index c978d72f..ebd95a0b 100644 --- a/configs/vite/src/index.ts +++ b/configs/vite/src/index.ts @@ -58,7 +58,7 @@ export async function createViteConfig( }, server: { hmr: true, - https: VITE_USE_HTTPS, + // https: VITE_USE_HTTPS, port: 3000, host: true, proxy: !VITE_USE_HTTPS ? resolveProxy(VITE_PROXY) : undefined, diff --git a/packages/router/src/routes/index.ts b/packages/router/src/routes/index.ts index cefb1158..392fbca6 100644 --- a/packages/router/src/routes/index.ts +++ b/packages/router/src/routes/index.ts @@ -10,7 +10,9 @@ import { loadRoutesFromModules } from '@vben/utils' export * from './basic' -const routeModuleRecord = import.meta.globEager('./modules/**/*.ts') as any +const routeModuleRecord = import.meta.glob('./modules/**/*.ts', { + eager: true, +}) as any const routeModules: RouteRecordRaw[] = loadRoutesFromModules(routeModuleRecord) export const layoutRoutes = [...routeModules] diff --git a/packages/vbenComponents/src/index.ts b/packages/vbenComponents/src/index.ts index a80020bb..9e02c4df 100644 --- a/packages/vbenComponents/src/index.ts +++ b/packages/vbenComponents/src/index.ts @@ -2,7 +2,6 @@ import type { App, Component } from 'vue' const projectName = 'Vben3' export const components = { install: (app: App) => { - // const comp = import.meta.globEager('./**/*.vue') /* 上面写法vite官方已弃用,详情见 https://cn.vitejs.dev/guide/migration-from-v2.html#importmetaglob */ const comp = import.meta.glob('./**/*.vue', { eager: true }) Object.keys(comp).forEach((k) => {