Commit 235d9bcd by zhangxingmin

push

parent 6976404d
......@@ -11,9 +11,9 @@ server {
add_header Cache-Control "no-store, no-cache, must-revalidate";
}
# 子应用 /cffp/ 路由
# 子应用 /cffp/ 路由(关键修正)
location /cffp/ {
try_files $uri $uri/ /cffp/index.html; # 移除 alias,直接使用 root
try_files $uri $uri/ /index.html; # 改为指向根目录的 index.html
}
# 禁止访问 .env 文件
......
// vite.config.js
import { defineConfig } from 'vite'
import { createVuePlugin } from 'vite-plugin-vue2'
import path from 'path'
export default defineConfig({
// 关键修改:设置 base 路径,与 Nginx 配置匹配
base: '/cffp/',
plugins: [createVuePlugin()],
resolve: {
extensions: ['.vue', '.js', '.ts', '.json'], // 添加 .ts 支持
extensions: ['.vue', '.js', '.ts', '.json'],
alias: {
'@': path.resolve(__dirname), // 指向项目根目录
'@api': path.resolve(__dirname, 'api') // 直接指向 api 目录
'@': path.resolve(__dirname),
'@api': path.resolve(__dirname, 'api')
}
},
// 开发服务器配置(可选)
server: {
port: 8080,
proxy: {
// 代理后端 API 请求,避免跨域问题
'/cffpApi': {
target: 'http://localhost:8080',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/cffpApi/, '')
}
}
},
// 生产环境构建配置
build: {
outDir: 'dist', // 输出目录
assetsDir: 'assets', // 静态资源目录
rollupOptions: {
output: {
// 确保生成的资源路径正确
assetFileNames: 'assets/[name].[hash].[ext]',
chunkFileNames: 'assets/[name].[hash].js',
entryFileNames: 'assets/[name].[hash].js'
}
}
}
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment