diff --git a/.eslintignore b/.eslintignore index 32b17dc..7385d52 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,4 +2,4 @@ public dist package.json !.prettierrc.cjs -src/vite-env.d.ts +env.d.ts diff --git a/env.d.ts b/env.d.ts new file mode 100644 index 0000000..4e8bca1 --- /dev/null +++ b/env.d.ts @@ -0,0 +1,27 @@ +interface ImportMetaEnv { + // Auto generate by env-parse + /** + * undefined + */ + readonly VITE_BASE_URL: string + /** + * undefined + */ + readonly VITE_PROXY: Record + /** + * undefined + */ + readonly VITE_FILE_URL: string + /** + * undefined + */ + readonly VITE_TEMPLATE_URL: string + /** + * undefined + */ + readonly VITE_ON_LINE_WEB_SOCKET_URL: string + /** + * undefined + */ + readonly VITE_LEARNING_WEB_SOCKET_URL: string +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 7cc317a..ee2614a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -68,6 +68,7 @@ "unplugin-vue-components": "^0.22.12", "vite": "^4.5.1", "vite-plugin-enhance-log": "^0.5.2", + "vite-plugin-env-parse": "^1.0.10", "vite-plugin-eslint": "^1.8.1", "vite-plugin-remove-console": "^2.2.0", "vue-eslint-parser": "^9.3.2" @@ -5966,6 +5967,15 @@ "vite": "^2.9.0 || ^3.0.0 || ^4.0.0" } }, + "node_modules/vite-plugin-env-parse": { + "version": "1.0.10", + "resolved": "https://registry.npmmirror.com/vite-plugin-env-parse/-/vite-plugin-env-parse-1.0.10.tgz", + "integrity": "sha512-7C3ixNz02ExrYCZRkAhXRWXqWktR/YO/SkrCdOUFR3GCXALUGt4xNhTTVZonKH8SpA4xe1wp2mS606MKZdvOpw==", + "dev": true, + "peerDependencies": { + "vite": "*" + } + }, "node_modules/vite-plugin-eslint": { "version": "1.8.1", "resolved": "https://registry.npmmirror.com/vite-plugin-eslint/-/vite-plugin-eslint-1.8.1.tgz", diff --git a/package.json b/package.json index 8bb9dbf..249ca3d 100644 --- a/package.json +++ b/package.json @@ -70,6 +70,7 @@ "unplugin-vue-components": "^0.22.12", "vite": "^4.5.1", "vite-plugin-enhance-log": "^0.5.2", + "vite-plugin-env-parse": "^1.0.10", "vite-plugin-eslint": "^1.8.1", "vite-plugin-remove-console": "^2.2.0", "vue-eslint-parser": "^9.3.2" diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts deleted file mode 100644 index ef6964f..0000000 --- a/src/vite-env.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -/// - -interface ImportMetaEnv { - readonly VITE_BASE_URL: string - readonly VITE_PROXY: string - readonly VITE_FILE_URL: string - readonly VITE_TEMPLATE_URL: string - readonly VITE_ON_LINE_WEB_SOCKET_URL: string - readonly VITE_LEARNING_WEB_SOCKET_URL: string -} - -interface ImportMeta { - readonly env: ImportMetaEnv -} diff --git a/vite.config.js b/vite.config.js index 6790793..e178e6c 100644 --- a/vite.config.js +++ b/vite.config.js @@ -10,11 +10,13 @@ import { // import basicSsl from "@vitejs/plugin-basic-ssl"; import removeConsole from "vite-plugin-remove-console"; import EnhanceLog from "vite-plugin-enhance-log"; +import { envParse } from "vite-plugin-env-parse"; export default ({ mode }) => { return defineConfig({ plugins: [ vue(), + envParse(), eslintPlugin(), removeConsole({ includes: [