update: 在项目中添加 vite-plugin-mkcert 插件,配置 HTTPS 和 CORS,优化代理设置,调整构建选项以支持手动分块和压缩设置
This commit is contained in:
parent
ecaca53dfa
commit
e6832941d5
|
@ -51,6 +51,7 @@
|
||||||
"@vitejs/plugin-vue": "^5.2.1",
|
"@vitejs/plugin-vue": "^5.2.1",
|
||||||
"sass": "^1.86.3",
|
"sass": "^1.86.3",
|
||||||
"sass-embedded": "^1.86.3",
|
"sass-embedded": "^1.86.3",
|
||||||
"vite": "^6.2.0"
|
"vite": "^6.2.0",
|
||||||
|
"vite-plugin-mkcert": "^1.17.8"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import vue from '@vitejs/plugin-vue'
|
||||||
// import electron from 'vite-plugin-electron'
|
// import electron from 'vite-plugin-electron'
|
||||||
// import vueDevTools from 'vite-plugin-vue-devtools'
|
// import vueDevTools from 'vite-plugin-vue-devtools'
|
||||||
|
|
||||||
|
import mkcert from "vite-plugin-mkcert";
|
||||||
// https://vite.dev/config/
|
// https://vite.dev/config/
|
||||||
export default defineConfig(({ command, mode }) => {
|
export default defineConfig(({ command, mode }) => {
|
||||||
const env = loadEnv(mode, process.cwd())
|
const env = loadEnv(mode, process.cwd())
|
||||||
|
@ -18,6 +19,11 @@ export default defineConfig(({ command, mode }) => {
|
||||||
return {
|
return {
|
||||||
plugins: [
|
plugins: [
|
||||||
vue(),
|
vue(),
|
||||||
|
mkcert({
|
||||||
|
source: 'coding',
|
||||||
|
autoUpgrade: true,
|
||||||
|
force: true,
|
||||||
|
}),
|
||||||
// electron({
|
// electron({
|
||||||
// entry: 'electron/main.js',
|
// entry: 'electron/main.js',
|
||||||
// }),
|
// }),
|
||||||
|
@ -36,12 +42,37 @@ export default defineConfig(({ command, mode }) => {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
|
host: true,
|
||||||
|
https: true,
|
||||||
|
cors: true,
|
||||||
proxy: {
|
proxy: {
|
||||||
'/api': {
|
'/api': {
|
||||||
target: env.VITE_APP_BASE_API,
|
target: env.VITE_APP_BASE_API,
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
rewrite: (path) => path.replace(/^\/api/, ''),
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue