diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..109cc85 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +# 1. 第一阶段:构建 +FROM node:20-alpine AS builder + +WORKDIR /app + +COPY package*.json ./ +RUN npm install + +COPY . . + +# 2. 根据 MODE 参数执行对应的打包命令 +RUN npm run build + +# 2. 第二阶段:部署 +FROM nginx:stable-alpine +COPY --from=builder /app/dist /usr/share/nginx/html +COPY ./nginx.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..3d36427 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,23 @@ +server { + listen 80; + listen [::]:80; + server_name localhost; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ /index.html; + + # 针对 HTML 文件设置不缓存 + if ($request_filename ~* .*\.(?:htm|html)$ ) { + add_header Cache-Control "no-cache, no-store, must-revalidate"; + } + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +} + + diff --git a/vue.config.js b/vue.config.js index 301a217..4fef609 100644 --- a/vue.config.js +++ b/vue.config.js @@ -1,8 +1,8 @@ const webpack = require('webpack'); module.exports = { - publicPath: '/plus-6/', - outputDir: "dist", + // publicPath: '/plus-6/', + // outputDir: "dist", transpileDependencies: true, productionSourceMap: false, devServer: {