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 } } },