From b5a4ebe2f652a780e4694407892254a77eedb9fb Mon Sep 17 00:00:00 2001 From: yangxu52 Date: Fri, 7 Mar 2025 12:17:41 +0800 Subject: [PATCH 1/2] =?UTF-8?q?chore:=20=E6=A0=87=E5=87=86=E5=8C=96tsconfi?= =?UTF-8?q?g=EF=BC=8C=E5=B9=B6=E6=94=B9=E4=BA=86=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=9A=84$schema?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 7 ++++--- tsconfig.json | 44 ++++++++++++++++++++++++-------------------- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index 86ceffc..5c68620 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "$schema": "https://json.schemastore.org/tsconfig", + "$schema": "https://json.schemastore.org/package", "name": "ruoyi-vue-plus", "version": "5.3.0", "description": "RuoYi-Vue-Plus多租户管理系统", @@ -52,6 +52,7 @@ "@types/crypto-js": "4.2.2", "@types/file-saver": "2.0.7", "@types/js-cookie": "3.0.6", + "@types/node": "^22.13.4", "@types/nprogress": "0.2.3", "@unocss/preset-attributify": "66.0.0", "@unocss/preset-icons": "66.0.0", @@ -67,7 +68,7 @@ "globals": "16.0.0", "prettier": "3.5.2", "sass": "1.84.0", - "typescript": "5.7.3", + "typescript": "~5.7.3", "unocss": "66.0.0", "unplugin-auto-import": "0.17.5", "unplugin-icons": "0.18.5", @@ -78,7 +79,7 @@ "vite-plugin-svg-icons-ng": "1.0.2", "vite-plugin-vue-devtools": "7.7.1", "vitest": "3.0.5", - "vue-tsc": "2.2.0" + "vue-tsc": "^2.2.2" }, "engines": { "node": ">=18.18.0", diff --git a/tsconfig.json b/tsconfig.json index 6315891..142d509 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,31 +1,35 @@ { + "$schema": "https://json.schemastore.org/tsconfig", "compilerOptions": { - "target": "esnext", - "module": "esnext", - // "useDefineForClassFields": true, - "moduleResolution": "bundler", + "baseUrl": ".", + // https://vite.dev/config/build-options.html#build-target + "target": "ES2020", + "module": "ESNext", + "moduleResolution": "Bundler", + "lib": ["ESNext", "DOM", "DOM.Iterable"], + "skipLibCheck": true, + // This setting lets you specify a file for storing incremental compilation information as a part of composite projects which enables faster building of larger TypeScript codebases. + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo", "strict": true, + "allowJs": true, "jsx": "preserve", - "strictNullChecks": false, "sourceMap": true, "resolveJsonModule": true, "esModuleInterop": true, - "strictFunctionTypes": false, - "lib": ["esnext", "dom"], - "noImplicitAny": false, - "baseUrl": ".", - "allowJs": true, - "experimentalDecorators": true, + "noEmit": true, "paths": { - "@/*": ["src/*"] + "@/*": ["./src/*"] }, - "types": ["vite/client"], - "skipLibCheck": true, - "removeComments": true, - // 允许默认导入 - "allowSyntheticDefaultImports": true, - "forceConsistentCasingInFileNames": true + "types": ["node", "vite/client"], + // 自定义配置 + "noImplicitAny": false, // 禁用 隐式的any错误 + "removeComments": true, // 移除 ts注释 + "experimentalDecorators": true, // 启用实验性的装饰器支持 + "strictFunctionTypes": false, // 禁用严格函数类型检查 + "strictNullChecks": false, // 禁用严格的空值检查 + "allowSyntheticDefaultImports": true, // 允许默认导入 + "forceConsistentCasingInFileNames": true // 强制在文件名中使用一致的大小写 }, - "include": ["src/**/*.ts", "src/**/*.vue", "src/types/**/*.d.ts", "vite.config.ts"], - "exclude": ["node_modules", "dist", "**/*.js", "**/*.md", "src/**/*.md"] + "include": ["src/**/.ts", "src/**/*.vue", "vite.config.ts", "vitest.config.ts", "eslint.config.ts"], + "exclude": ["node_modules", "dist", "src/**/__tests__/*"] } From 7784709cae5d3f79f6a021d435e87863cd5b7e5b Mon Sep 17 00:00:00 2001 From: yangxu52 Date: Fri, 7 Mar 2025 12:24:03 +0800 Subject: [PATCH 2/2] =?UTF-8?q?chore:=20=E4=BC=98=E5=8C=96postcss=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除autoprefixer的浏览器版本覆盖,使用package.json来定义, - browerserlist定义对齐vite的构建目标 https://vite.dev/config/build-options.html#build-target - atRule中charset已经限定配置charset,判断多余 - 顺手删了~路径别名,此项未使用,且tsconfig也没配置 --- package.json | 8 +++++++- vite.config.ts | 9 ++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 5c68620..1dac5c7 100644 --- a/package.json +++ b/package.json @@ -84,5 +84,11 @@ "engines": { "node": ">=18.18.0", "npm": ">=8.9.0" - } + }, + "browserslist": [ + "Chrome >= 87", + "Edge >= 88", + "Safari >= 14", + "Firefox >= 78" + ] } diff --git a/vite.config.ts b/vite.config.ts index b29dd40..58ca5f2 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -12,7 +12,6 @@ export default defineConfig(({ mode, command }) => { base: env.VITE_APP_CONTEXT_PATH, resolve: { alias: { - '~': path.resolve(__dirname, './'), '@': path.resolve(__dirname, './src') }, extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'] @@ -43,16 +42,12 @@ export default defineConfig(({ mode, command }) => { postcss: { plugins: [ // 浏览器兼容性 - autoprefixer({ - overrideBrowserslist: ['Android 4.1', 'iOS 7.1', 'Chrome > 31', 'ff > 31', 'ie >= 8'] - }), + autoprefixer(), { postcssPlugin: 'internal:charset-removal', AtRule: { charset: (atRule) => { - if (atRule.name === 'charset') { - atRule.remove(); - } + atRule.remove(); } } }