2025-10-08 14:11:54 +08:00
|
|
|
import { defineConfig } from 'vite'
|
|
|
|
|
import vue from '@vitejs/plugin-vue'
|
|
|
|
|
import { VitePWA } from 'vite-plugin-pwa'
|
|
|
|
|
import { resolve } from 'path'
|
|
|
|
|
|
|
|
|
|
// https://vitejs.dev/config/
|
|
|
|
|
export default defineConfig({
|
|
|
|
|
plugins: [
|
|
|
|
|
vue(),
|
|
|
|
|
VitePWA({
|
|
|
|
|
registerType: 'autoUpdate',
|
|
|
|
|
workbox: {
|
|
|
|
|
cleanupOutdatedCaches: true,
|
|
|
|
|
skipWaiting: true,
|
|
|
|
|
clientsClaim: true
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
// 基础路径
|
|
|
|
|
base: '/schoolNewsWeb/',
|
2025-10-18 18:19:19 +08:00
|
|
|
file: {
|
|
|
|
|
downloadUrl: "http://127.0.0.1:8081/schoolNewsServ/file/download/"
|
|
|
|
|
},
|
2025-10-08 14:11:54 +08:00
|
|
|
|
|
|
|
|
// 输出目录
|
|
|
|
|
build: {
|
|
|
|
|
outDir: 'dist',
|
|
|
|
|
assetsDir: 'static',
|
|
|
|
|
sourcemap: false,
|
|
|
|
|
chunkSizeWarningLimit: 1500,
|
|
|
|
|
rollupOptions: {
|
|
|
|
|
output: {
|
|
|
|
|
manualChunks: {
|
|
|
|
|
'vue-vendor': ['vue', 'vue-router', 'vuex'],
|
|
|
|
|
'element-plus': ['element-plus']
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 路径别名
|
|
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
|
|
|
|
'@': resolve(__dirname, 'src')
|
|
|
|
|
},
|
|
|
|
|
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 环境变量
|
|
|
|
|
define: {
|
|
|
|
|
'process.env.BASE_URL': JSON.stringify('/schoolNewsWeb/'),
|
|
|
|
|
'process.env.VITE_API_BASE_URL': JSON.stringify('/api'),
|
|
|
|
|
'process.env.VITE_APP_TITLE': JSON.stringify('校园新闻管理系统')
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 开发服务器配置
|
|
|
|
|
server: {
|
|
|
|
|
host: '0.0.0.0',
|
|
|
|
|
port: 8080,
|
2025-10-23 18:57:31 +08:00
|
|
|
open: '/schoolNewsWeb/',
|
2025-10-08 14:11:54 +08:00
|
|
|
|
|
|
|
|
// 代理配置
|
|
|
|
|
proxy: {
|
|
|
|
|
'/api': {
|
|
|
|
|
target: 'http://127.0.0.1:8081/schoolNewsServ',
|
|
|
|
|
changeOrigin: true,
|
|
|
|
|
rewrite: (path) => path.replace(/^\/api/, ''),
|
|
|
|
|
configure: (proxy, options) => {
|
|
|
|
|
proxy.on('proxyReq', (proxyReq, req, res) => {
|
|
|
|
|
console.log('代理请求:', req.method, req.url, '->', proxyReq.path);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// CSS 配置
|
|
|
|
|
css: {
|
|
|
|
|
preprocessorOptions: {
|
|
|
|
|
scss: {
|
|
|
|
|
additionalData: ''
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|