From e6832941d5fdea54af9a8ff873df82bde92dcea2 Mon Sep 17 00:00:00 2001 From: Lexcubia Date: Mon, 21 Apr 2025 14:17:50 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E5=9C=A8=E9=A1=B9=E7=9B=AE=E4=B8=AD?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20vite-plugin-mkcert=20=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=EF=BC=8C=E9=85=8D=E7=BD=AE=20HTTPS=20=E5=92=8C=20CORS=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=90=86=E8=AE=BE=E7=BD=AE=EF=BC=8C?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=9E=84=E5=BB=BA=E9=80=89=E9=A1=B9=E4=BB=A5?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=89=8B=E5=8A=A8=E5=88=86=E5=9D=97=E5=92=8C?= =?UTF-8?q?=E5=8E=8B=E7=BC=A9=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 3 ++- vite.config.js | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 5579619..8376ab6 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,7 @@ "@vitejs/plugin-vue": "^5.2.1", "sass": "^1.86.3", "sass-embedded": "^1.86.3", - "vite": "^6.2.0" + "vite": "^6.2.0", + "vite-plugin-mkcert": "^1.17.8" } } diff --git a/vite.config.js b/vite.config.js index 584304d..0b6358f 100644 --- a/vite.config.js +++ b/vite.config.js @@ -5,6 +5,7 @@ import vue from '@vitejs/plugin-vue' // import electron from 'vite-plugin-electron' // import vueDevTools from 'vite-plugin-vue-devtools' +import mkcert from "vite-plugin-mkcert"; // https://vite.dev/config/ export default defineConfig(({ command, mode }) => { const env = loadEnv(mode, process.cwd()) @@ -18,6 +19,11 @@ export default defineConfig(({ command, mode }) => { return { plugins: [ vue(), + mkcert({ + source: 'coding', + autoUpgrade: true, + force: true, + }), // electron({ // entry: 'electron/main.js', // }), @@ -36,12 +42,37 @@ export default defineConfig(({ command, mode }) => { } }, server: { + host: true, + https: true, + cors: true, proxy: { '/api': { target: env.VITE_APP_BASE_API, changeOrigin: true, rewrite: (path) => path.replace(/^\/api/, ''), - secure: false + secure: false, + configure: (proxy, options) => { + proxy.on('proxyReq', (proxyReq, req, res) => { + proxyReq.setHeader('Origin', env.VITE_APP_BASE_API); + proxyReq.setHeader('Access-Control-Request-Method', '*'); + }); + } + } + } + }, + build: { + rollupOptions: { + output: { + manualChunks: { + 'vendor': ['vue', 'vue-router', 'pinia'] + } + } + }, + chunkSizeWarningLimit: 1500, + terserOptions: { + compress: { + // drop_console: true, + drop_debugger: true } } },