Browse Source

chore: config ts-config

vben 1 year ago
parent
commit
08d4e34b77

+ 0 - 3
.env.development

@@ -9,9 +9,6 @@ VITE_PUBLIC_PATH = /
 VITE_PROXY = [["/basic-api","http://localhost:3000"],["/upload","http://localhost:3300/upload"]]
 # VITE_PROXY=[["/api","https://vvbin.cn/test"]]
 
-# Delete console
-VITE_DROP_CONSOLE = false
-
 # Basic interface address SPA
 VITE_GLOB_API_URL=/basic-api
 

+ 0 - 3
.env.production

@@ -4,9 +4,6 @@ VITE_USE_MOCK = true
 # public path
 VITE_PUBLIC_PATH = /
 
-# Delete console
-VITE_DROP_CONSOLE = true
-
 # Whether to enable gzip or brotli compression
 # Optional: gzip | brotli | none
 # If you need multiple forms, you can use `,` to separate

+ 0 - 3
.env.test

@@ -5,9 +5,6 @@ VITE_USE_MOCK = true
 # public path
 VITE_PUBLIC_PATH = /
 
-# Delete console
-VITE_DROP_CONSOLE = true
-
 # Whether to enable gzip or brotli compression
 # Optional: gzip | brotli | none
 # If you need multiple forms, you can use `,` to separate

+ 4 - 0
internal/eslint-config/tsconfig.json

@@ -0,0 +1,4 @@
+{
+  "extends": "@vben/ts-config/node.json",
+  "include": ["src"]
+}

+ 4 - 0
internal/stylelint-config/tsconfig.json

@@ -0,0 +1,4 @@
+{
+  "extends": "@vben/ts-config/node.json",
+  "include": ["src"]
+}

+ 27 - 0
internal/ts-config/base.json

@@ -0,0 +1,27 @@
+{
+  "$schema": "https://json.schemastore.org/tsconfig",
+  "display": "Base",
+  "compilerOptions": {
+    "target": "ESNext",
+    "module": "ESNext",
+    "moduleResolution": "node",
+    "strict": true,
+    "declaration": true,
+    "noImplicitOverride": true,
+    "noUnusedLocals": true,
+    "esModuleInterop": true,
+    "useUnknownInCatchVariables": false,
+    "composite": false,
+    "declarationMap": false,
+    "forceConsistentCasingInFileNames": true,
+    "inlineSources": false,
+    "isolatedModules": true,
+    "skipLibCheck": true,
+    "noUnusedParameters": false,
+    "preserveWatchOutput": true,
+    "experimentalDecorators": true,
+    "resolveJsonModule": true,
+    "removeComments": true
+  },
+  "exclude": ["**/node_modules/**", "**/dist/**"]
+}

+ 12 - 0
internal/ts-config/node.json

@@ -0,0 +1,12 @@
+{
+  "$schema": "https://json.schemastore.org/tsconfig",
+  "display": "Node Config",
+  "extends": "./base.json",
+  "compilerOptions": {
+    "lib": ["ESNext"],
+    "types": ["vite/client"],
+    "noImplicitAny": true,
+    "sourceMap": true,
+    "noEmit": true
+  }
+}

+ 5 - 0
internal/ts-config/package.json

@@ -3,5 +3,10 @@
   "version": "1.0.0",
   "private": true,
   "license": "MIT",
+  "files": [
+    "base.json",
+    "node.json",
+    "vue.json"
+  ],
   "devDependencies": {}
 }

+ 10 - 0
internal/ts-config/vue.json

@@ -0,0 +1,10 @@
+{
+  "$schema": "https://json.schemastore.org/tsconfig",
+  "display": "Vue Library",
+  "extends": "./base.json",
+  "compilerOptions": {
+    "jsx": "preserve",
+    "lib": ["ESNext", "DOM"],
+    "noImplicitAny": false
+  }
+}

+ 1 - 0
package.json

@@ -135,6 +135,7 @@
     "@types/sortablejs": "^1.15.1",
     "@vben/eslint-config": "workspace:*",
     "@vben/stylelint-config": "workspace:*",
+    "@vben/ts-config": "workspace:*",
     "@vitejs/plugin-vue": "^4.1.0",
     "@vitejs/plugin-vue-jsx": "^3.0.1",
     "@vue/compiler-sfc": "^3.2.47",

File diff suppressed because it is too large
+ 155 - 387
pnpm-lock.yaml


+ 2 - 21
tsconfig.json

@@ -1,27 +1,8 @@
 {
+  "extends": "@vben/ts-config/vue.json",
   "compilerOptions": {
-    "target": "esnext",
-    "module": "esnext",
-    "moduleResolution": "node",
-    "strict": true,
-    "noLib": false,
-    "forceConsistentCasingInFileNames": true,
-    "allowSyntheticDefaultImports": true,
-    "strictFunctionTypes": false,
-    "jsx": "preserve",
-    "baseUrl": ".",
-    "allowJs": true,
-    "sourceMap": true,
-    "esModuleInterop": true,
-    "resolveJsonModule": true,
-    "noUnusedLocals": true,
-    "noUnusedParameters": true,
-    "experimentalDecorators": true,
-    "lib": ["dom", "esnext"],
-    "noImplicitAny": false,
-    "skipLibCheck": true,
+    "baseUrl": "./",
     "types": ["vite/client"],
-    "removeComments": true,
     "paths": {
       "/@/*": ["src/*"],
       "/#/*": ["types/*"]

+ 0 - 1
types/global.d.ts

@@ -63,7 +63,6 @@ declare global {
     VITE_GLOB_APP_TITLE: string;
     VITE_GLOB_APP_SHORT_NAME: string;
     VITE_USE_CDN: boolean;
-    VITE_DROP_CONSOLE: boolean;
     VITE_BUILD_COMPRESS: 'gzip' | 'brotli' | 'none';
     VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE: boolean;
   }

+ 2 - 14
vite.config.ts

@@ -27,7 +27,7 @@ export default async ({ command, mode }: ConfigEnv): Promise<UserConfig> => {
   // The boolean type read by loadEnv is a string. This function can be converted to boolean type
   const viteEnv = wrapperEnv(env);
 
-  const { VITE_PUBLIC_PATH, VITE_PROXY, VITE_DROP_CONSOLE } = viteEnv;
+  const { VITE_PUBLIC_PATH, VITE_PROXY } = viteEnv;
 
   const isBuild = command === 'build';
 
@@ -58,24 +58,12 @@ export default async ({ command, mode }: ConfigEnv): Promise<UserConfig> => {
       proxy: createProxy(VITE_PROXY),
     },
     esbuild: {
-      drop: VITE_DROP_CONSOLE ? ['console', 'debugger'] : [],
+      drop: ['console', 'debugger'],
     },
     build: {
       target: 'es2015',
       cssTarget: 'chrome80',
       outDir: OUTPUT_DIR,
-      // minify: 'terser',
-      /**
-       * 当 minify=“minify:'terser'” 解开注释
-       * Uncomment when minify="minify:'terser'"
-       */
-      // terserOptions: {
-      //   compress: {
-      //     keep_infinity: true,
-      //     drop_console: VITE_DROP_CONSOLE,
-      //   },
-      // },
-      // Turning off brotliSize display can slightly reduce packaging time
       reportCompressedSize: false,
       chunkSizeWarningLimit: 2000,
     },

Some files were not shown because too many files changed in this diff