make frontend build lighter for HF
Browse files- Dockerfile +6 -1
- web/vite.config.js +4 -0
Dockerfile
CHANGED
|
@@ -6,7 +6,12 @@ COPY web/bun.lock .
|
|
| 6 |
RUN bun install
|
| 7 |
COPY ./web .
|
| 8 |
COPY ./VERSION .
|
| 9 |
-
RUN
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
FROM golang:alpine AS builder2
|
| 12 |
ENV GO111MODULE=on CGO_ENABLED=0
|
|
|
|
| 6 |
RUN bun install
|
| 7 |
COPY ./web .
|
| 8 |
COPY ./VERSION .
|
| 9 |
+
RUN BROWSERSLIST_IGNORE_OLD_DATA=1 \
|
| 10 |
+
NODE_OPTIONS=--max-old-space-size=4096 \
|
| 11 |
+
VITE_BUILD_LITE=true \
|
| 12 |
+
DISABLE_ESLINT_PLUGIN='true' \
|
| 13 |
+
VITE_REACT_APP_VERSION=$(cat VERSION) \
|
| 14 |
+
bun run build
|
| 15 |
|
| 16 |
FROM golang:alpine AS builder2
|
| 17 |
ENV GO111MODULE=on CGO_ENABLED=0
|
web/vite.config.js
CHANGED
|
@@ -27,6 +27,7 @@ const { vitePluginSemi } = pkg;
|
|
| 27 |
// https://vitejs.dev/config/
|
| 28 |
export default defineConfig(({ command }) => {
|
| 29 |
const isBuild = command === 'build';
|
|
|
|
| 30 |
return {
|
| 31 |
resolve: {
|
| 32 |
alias: {
|
|
@@ -69,6 +70,9 @@ export default defineConfig(({ command }) => {
|
|
| 69 |
},
|
| 70 |
},
|
| 71 |
build: {
|
|
|
|
|
|
|
|
|
|
| 72 |
rollupOptions: {
|
| 73 |
output: {
|
| 74 |
manualChunks: {
|
|
|
|
| 27 |
// https://vitejs.dev/config/
|
| 28 |
export default defineConfig(({ command }) => {
|
| 29 |
const isBuild = command === 'build';
|
| 30 |
+
const buildLite = process.env.VITE_BUILD_LITE === 'true';
|
| 31 |
return {
|
| 32 |
resolve: {
|
| 33 |
alias: {
|
|
|
|
| 70 |
},
|
| 71 |
},
|
| 72 |
build: {
|
| 73 |
+
// 在 CI/受限环境里使用轻量构建,避免内存压力导致卡住
|
| 74 |
+
minify: buildLite ? false : 'esbuild',
|
| 75 |
+
cssCodeSplit: buildLite ? false : true,
|
| 76 |
rollupOptions: {
|
| 77 |
output: {
|
| 78 |
manualChunks: {
|