From 3d01b968c0da16381fc9f599cadde1b355bde638 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=BA=91=E6=B5=B7?= Date: Tue, 19 Sep 2023 13:55:23 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20update=20nginx.conf=20=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E5=9B=BA=E5=AE=9A=E7=BC=96=E8=AF=91=E5=85=A5=E5=8F=A3?= =?UTF-8?q?=E5=8F=AF=E8=83=BD=E5=AF=BC=E8=87=B4=E6=B5=8F=E8=A7=88=E5=99=A8?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=BC=93=E5=AD=98js=E6=96=87=E4=BB=B6?= =?UTF-8?q?=EF=BC=8C=E8=80=8C=E6=AD=A4=E9=85=8D=E7=BD=AE=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E8=A7=A3=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nginx.conf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nginx.conf b/nginx.conf index ebf5e8de70d..1e21a8673ae 100644 --- a/nginx.conf +++ b/nginx.conf @@ -30,6 +30,9 @@ http { add_header 'Content-Length' 0; return 204; } + if ($request_filename ~* ^.*?.(html|htm|js)$) { + add_header Cache-Control no-cache; + } } } } From c2ea4749c561f857cbe876ffa46ae9dd4bac72c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=BA=91=E6=B5=B7?= Date: Wed, 27 Dec 2023 12:00:05 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0docker=E6=89=93?= =?UTF-8?q?=E5=8C=85=E9=80=BB=E8=BE=91=EF=BC=9A=20=E5=8E=9F=E6=9C=AC?= =?UTF-8?q?=E5=9B=BA=E5=AE=9A=E7=9A=84entry=E6=98=AF=E4=B8=BA=E4=BA=86?= =?UTF-8?q?=E6=96=B9=E4=B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87=8F=E7=9A=84=E6=96=B9=E5=BC=8F=E5=81=9A?= =?UTF-8?q?=20=E5=8D=95=E9=95=9C=E5=83=8F=E6=89=93=E5=8C=85=E5=A4=9A?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E7=9A=84=E9=80=82=E9=85=8D=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 5 ++--- internal/vite-config/src/config/application.ts | 4 ++-- nginx.conf | 7 ++++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 13112f6fc45..fb1233a9fb5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ MAINTAINER Adoin 'adoin@qq.com' WORKDIR /app COPY . ./ # 设置 node 阿里镜像 -RUN npm config set registry https://registry.npm.taobao.org +RUN npm config set registry https://registry.npmmirror.com # 设置--max-old-space-size ENV NODE_OPTIONS=--max-old-space-size=16384 # 设置阿里镜像、pnpm、依赖、编译 @@ -20,7 +20,6 @@ COPY --from=build-stage /app/dist /usr/share/nginx/html/dist COPY --from=build-stage /app/nginx.conf /etc/nginx/nginx.conf EXPOSE 80 ## 将/usr/share/nginx/html/dist/assets/index.js 和/usr/share/nginx/html/dist/_app.config.js中的"$vg_base_url"替换为环境变量中的VG_BASE_URL,$vg_sub_domain 替换成VG_SUB_DOMAIN,$vg_default_user替换成VG_DEFAULT_USER,$vg_default_password替换成VG_DEFAULT_PASSWORD 而后启动nginx -CMD sed -i "s|__vg_base_url|$VG_BASE_URL|g" /usr/share/nginx/html/dist/assets/index.js && \ - sed -i "s|__vg_base_url|$VG_BASE_URL|g" /usr/share/nginx/html/dist/_app.config.js && \ +CMD sed -i "s|__vg_base_url|$VG_BASE_URL|g" /usr/share/nginx/html/dist/assets/entry/index-*.js /usr/share/nginx/html/dist/_app.config.js && \ nginx -g 'daemon off;' RUN echo "🎉 架 🎉 设 🎉 成 🎉 功 🎉" diff --git a/internal/vite-config/src/config/application.ts b/internal/vite-config/src/config/application.ts index 1a24f1751d3..bd6d6ca4500 100644 --- a/internal/vite-config/src/config/application.ts +++ b/internal/vite-config/src/config/application.ts @@ -36,7 +36,7 @@ function defineApplicationConfig(defineOptions: DefineOptions = {}) { }); const pathResolve = (pathname: string) => resolve(root, '.', pathname); - + const timestamp = new Date().getTime(); const applicationConfig: UserConfig = { base: VITE_PUBLIC_PATH, resolve: { @@ -64,7 +64,7 @@ function defineApplicationConfig(defineOptions: DefineOptions = {}) { rollupOptions: { output: { // 入口文件名 - entryFileNames: 'assets/[name].js', + entryFileNames: `assets/entry/[name]-[hash]-${timestamp}.js`, manualChunks: { vue: ['vue', 'pinia', 'vue-router'], antd: ['ant-design-vue', '@ant-design/icons-vue'], diff --git a/nginx.conf b/nginx.conf index 1e21a8673ae..a0a405d6d02 100644 --- a/nginx.conf +++ b/nginx.conf @@ -30,9 +30,10 @@ http { add_header 'Content-Length' 0; return 204; } - if ($request_filename ~* ^.*?.(html|htm|js)$) { - add_header Cache-Control no-cache; - } +# docker 改造之后不再需要 +# if ($request_filename ~* ^.*?.(html|htm|js)$) { +# add_header Cache-Control no-cache; +# } } } }