网站和推流制作完成
This commit is contained in:
147
EyeVue/vite.config.ts
Normal file
147
EyeVue/vite.config.ts
Normal file
@@ -0,0 +1,147 @@
|
||||
import { defineConfig } from "vite";
|
||||
import vue from "@vitejs/plugin-vue";
|
||||
import path from "path";
|
||||
import viteCompression from "vite-plugin-compression";
|
||||
import { ViteImageOptimizer } from "vite-plugin-image-optimizer";
|
||||
import { fontConfig } from "./src/config/font";
|
||||
|
||||
import cesium from 'vite-plugin-cesium'
|
||||
|
||||
export default defineConfig({
|
||||
base: "/",
|
||||
build: {
|
||||
outDir: "dist",
|
||||
assetsDir: "assets",
|
||||
minify: "terser",
|
||||
sourcemap: false,
|
||||
chunkSizeWarningLimit: 1500,
|
||||
terserOptions: {
|
||||
compress: {
|
||||
drop_console: true,
|
||||
drop_debugger: true,
|
||||
pure_funcs: ["console.log"],
|
||||
},
|
||||
format: {
|
||||
comments: /@license/i,
|
||||
},
|
||||
},
|
||||
rollupOptions: {
|
||||
output: {
|
||||
manualChunks: {
|
||||
vendor: ["vue", "vue-router"],
|
||||
},
|
||||
chunkFileNames: "assets/js/[name]-[hash].js",
|
||||
entryFileNames: "assets/js/[name]-[hash].js",
|
||||
assetFileNames: "assets/[ext]/[name]-[hash].[ext]",
|
||||
},
|
||||
},
|
||||
cssCodeSplit: true,
|
||||
cssMinify: true,
|
||||
},
|
||||
plugins: [
|
||||
cesium(),
|
||||
vue(),
|
||||
viteCompression({
|
||||
verbose: true,
|
||||
disable: false,
|
||||
threshold: 10240,
|
||||
algorithm: "gzip",
|
||||
ext: ".gz",
|
||||
}),
|
||||
ViteImageOptimizer({
|
||||
test: /\.(jpe?g|png|gif|svg)$/i,
|
||||
exclude: undefined,
|
||||
include: undefined,
|
||||
includePublic: true,
|
||||
logStats: true,
|
||||
ansiColors: true,
|
||||
svg: {
|
||||
multipass: true,
|
||||
plugins: [
|
||||
{
|
||||
name: "preset-default",
|
||||
params: {
|
||||
overrides: {
|
||||
removeViewBox: false,
|
||||
removeEmptyAttrs: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
png: {
|
||||
quality: 80,
|
||||
},
|
||||
jpeg: {
|
||||
quality: 80,
|
||||
},
|
||||
jpg: {
|
||||
quality: 80,
|
||||
},
|
||||
tiff: {
|
||||
quality: 80,
|
||||
},
|
||||
gif: undefined,
|
||||
webp: {
|
||||
quality: 80,
|
||||
},
|
||||
avif: {
|
||||
quality: 80,
|
||||
},
|
||||
}),
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
"@": path.resolve(__dirname, "src"),
|
||||
},
|
||||
},
|
||||
server: {
|
||||
host: "0.0.0.0", // 监听所有网络接口
|
||||
port: 5173, // 确保端口设置正确
|
||||
allowedHosts: ["w.godserver.cn",'godserver.cn','www.godserver.cn','rbq.college'], // 允许的主机列表
|
||||
proxy: {
|
||||
"/api": {
|
||||
target: "http://127.0.0.1:8080", // 注意这里去掉了后面的/api,Vite会自动拼接
|
||||
changeOrigin: true, // 关键:修改请求头中的Origin为目标服务器地址
|
||||
rewrite: (path) => path.replace(/^\/api/, '/api'), // 保留/api前缀
|
||||
headers: {
|
||||
// 添加可能需要的请求头,解决403问题
|
||||
"Origin": "http://127.0.0.1:8080",
|
||||
"Referer": "http://127.0.0.1:8080",
|
||||
"Accept": "application/json",
|
||||
"Cache-Control": "no-cache",
|
||||
"Pragma": "no-cache"
|
||||
},
|
||||
},
|
||||
// 代理HLS流请求
|
||||
"/hls": {
|
||||
target: "http://127.0.0.1:8080",
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path, // 不修改路径
|
||||
headers: {
|
||||
"Origin": "http://127.0.0.1:8080",
|
||||
"Referer": "http://127.0.0.1:8080",
|
||||
"Cache-Control": "no-cache"
|
||||
}
|
||||
},
|
||||
// 代理历史视频请求
|
||||
"/saved": {
|
||||
target: "http://127.0.0.1:8080",
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path,
|
||||
headers: {
|
||||
"Origin": "http://127.0.0.1:8080",
|
||||
"Referer": "http://127.0.0.1:8080",
|
||||
"Cache-Control": "no-cache"
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
define: {
|
||||
__VUE_OPTIONS_API__: true,
|
||||
__VUE_PROD_DEVTOOLS__: false,
|
||||
"process.env.VITE_FONT_URL": JSON.stringify(fontConfig.url),
|
||||
"process.env.VITE_FONT_ENABLED": JSON.stringify(fontConfig.enabled),
|
||||
"process.env.VITE_FONT_PRELOAD": JSON.stringify(fontConfig.preload),
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user