Skip to content

Commit 6831340

Browse files
silverwindclaude
andcommitted
Migrate from webpack to Vite 8
Replace webpack with Vite 8 (Rolldown) as the frontend bundler. Key changes: - Replace webpack.config.ts with vite.config.ts using Rolldown - Use native ES modules with import maps for cache busting - Build web components as a separate blocking IIFE bundle to prevent flash of unstyled content (same behavior as webpack's blocking script) - Update all dynamic imports from webpack chunk comments to standard dynamic import() syntax - Replace process.env.TEST with import.meta.env.MODE - Add vite/client types to tsconfig.json - Update Monaco error suppression regex for new chunk names - Rename WEBPACK_* Makefile variables to FRONTEND_* Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
1 parent 28e09ff commit 6831340

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+792
-1648
lines changed

Makefile

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ LINUX_ARCHS ?= linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64,linux/r
120120
GO_TEST_PACKAGES ?= $(filter-out $(shell $(GO) list code.gitea.io/gitea/models/migrations/...) code.gitea.io/gitea/tests/integration/migration-test code.gitea.io/gitea/tests code.gitea.io/gitea/tests/integration,$(shell $(GO) list ./... | grep -v /vendor/))
121121
MIGRATE_TEST_PACKAGES ?= $(shell $(GO) list code.gitea.io/gitea/models/migrations/...)
122122

123-
WEBPACK_SOURCES := $(shell find web_src/js web_src/css -type f)
124-
WEBPACK_CONFIGS := webpack.config.ts tailwind.config.ts
125-
WEBPACK_DEST := public/assets/js/index.js public/assets/css/index.css
126-
WEBPACK_DEST_ENTRIES := public/assets/js public/assets/css public/assets/fonts
123+
FRONTEND_SOURCES := $(shell find web_src/js web_src/css -type f)
124+
FRONTEND_CONFIGS := vite.config.ts tailwind.config.ts
125+
FRONTEND_DEST := public/assets/js/index.js public/assets/js/webcomponents.js public/assets/css/index.css
126+
FRONTEND_DEST_ENTRIES := public/assets/js public/assets/css public/assets/fonts
127127

128128
BINDATA_DEST_WILDCARD := modules/migration/bindata.* modules/public/bindata.* modules/options/bindata.* modules/templates/bindata.*
129129

@@ -199,7 +199,7 @@ git-check:
199199

200200
.PHONY: clean-all
201201
clean-all: clean ## delete backend, frontend and integration files
202-
rm -rf $(WEBPACK_DEST_ENTRIES) node_modules
202+
rm -rf $(FRONTEND_DEST_ENTRIES) node_modules
203203

204204
.PHONY: clean
205205
clean: ## delete backend and integration files
@@ -381,8 +381,8 @@ watch: ## watch everything and continuously rebuild
381381

382382
.PHONY: watch-frontend
383383
watch-frontend: node_modules ## watch frontend files and continuously rebuild
384-
@rm -rf $(WEBPACK_DEST_ENTRIES)
385-
NODE_ENV=development $(NODE_VARS) pnpm exec webpack --watch --progress --disable-interpret
384+
@rm -rf $(FRONTEND_DEST_ENTRIES)
385+
NODE_ENV=development $(NODE_VARS) pnpm exec vite build --watch
386386

387387
.PHONY: watch-backend
388388
watch-backend: ## watch backend files and continuously rebuild
@@ -645,7 +645,7 @@ install: $(wildcard *.go)
645645
build: frontend backend ## build everything
646646

647647
.PHONY: frontend
648-
frontend: $(WEBPACK_DEST) ## build frontend files
648+
frontend: $(FRONTEND_DEST) ## build frontend files
649649

650650
.PHONY: backend
651651
backend: generate-backend $(EXECUTABLE) ## build backend files
@@ -776,15 +776,15 @@ update-py: node_modules ## update py dependencies
776776
uv sync
777777
@touch .venv
778778

779-
.PHONY: webpack
780-
webpack: $(WEBPACK_DEST) ## build webpack files
779+
.PHONY: vite
780+
vite: $(FRONTEND_DEST) ## build vite files
781781

782-
$(WEBPACK_DEST): $(WEBPACK_SOURCES) $(WEBPACK_CONFIGS) pnpm-lock.yaml
782+
$(FRONTEND_DEST): $(FRONTEND_SOURCES) $(FRONTEND_CONFIGS) pnpm-lock.yaml
783783
@$(MAKE) -s node_modules
784-
@rm -rf $(WEBPACK_DEST_ENTRIES)
785-
@echo "Running webpack..."
786-
@BROWSERSLIST_IGNORE_OLD_DATA=true $(NODE_VARS) pnpm exec webpack --disable-interpret
787-
@touch $(WEBPACK_DEST)
784+
@rm -rf $(FRONTEND_DEST_ENTRIES)
785+
@echo "Running vite build..."
786+
@$(NODE_VARS) pnpm exec vite build
787+
@touch $(FRONTEND_DEST)
788788

789789
.PHONY: svg
790790
svg: node_modules ## build svg files

eslint.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ export default defineConfig([
372372
'import-x/no-unresolved': [2, {commonjs: true, ignore: ['\\?.+$']}],
373373
'import-x/no-unused-modules': [0], // incompatible with eslint 9
374374
'import-x/no-useless-path-segments': [2, {commonjs: true}],
375-
'import-x/no-webpack-loader-syntax': [2],
375+
'import-x/no-webpack-loader-syntax': [0],
376376
'import-x/order': [0],
377377
'import-x/prefer-default-export': [0],
378378
'import-x/unambiguous': [0],
@@ -1007,6 +1007,6 @@ export default defineConfig([
10071007
},
10081008
{
10091009
files: ['web_src/**/*'],
1010-
languageOptions: {globals: {...globals.browser, ...globals.webpack}},
1010+
languageOptions: {globals: globals.browser},
10111011
},
10121012
]);

modules/markup/render.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ func RenderWithRenderer(ctx *RenderContext, renderer Renderer, input io.Reader,
240240
extraStyleHref := setting.AppSubURL + "/assets/css/external-render-iframe.css"
241241
extraScriptSrc := setting.AppSubURL + "/assets/js/external-render-iframe.js"
242242
// "<script>" must go before "<link>", to make Golang's http.DetectContentType() can still recognize the content as "text/html"
243-
extraHeadHTML = htmlutil.HTMLFormat(`<script src="%s"></script><link rel="stylesheet" href="%s">`, extraScriptSrc, extraStyleHref)
243+
extraHeadHTML = htmlutil.HTMLFormat(`<script type="module" src="%s"></script><link rel="stylesheet" href="%s">`, extraScriptSrc, extraStyleHref)
244244
}
245245

246246
ctx.usedByRender = true

package.json

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
"@primer/octicons": "19.22.0",
1919
"@resvg/resvg-wasm": "2.6.2",
2020
"@silverwind/vue3-calendar-heatmap": "2.1.1",
21-
"@techknowlogick/license-checker-webpack-plugin": "0.3.0",
22-
"add-asset-webpack-plugin": "3.1.1",
21+
"@vitejs/plugin-vue": "6.0.5",
2322
"ansi_up": "6.0.6",
2423
"asciinema-player": "3.15.1",
2524
"chart.js": "4.5.1",
@@ -29,25 +28,21 @@
2928
"colord": "2.9.3",
3029
"compare-versions": "6.1.1",
3130
"cropperjs": "1.6.2",
32-
"css-loader": "7.1.4",
3331
"dayjs": "1.11.19",
3432
"dropzone": "6.0.0-beta.2",
3533
"easymde": "2.20.0",
36-
"esbuild-loader": "4.4.2",
3734
"htmx.org": "2.0.8",
3835
"idiomorph": "0.7.4",
3936
"jquery": "4.0.0",
4037
"js-yaml": "4.1.1",
4138
"katex": "0.16.37",
4239
"mermaid": "11.12.3",
43-
"mini-css-extract-plugin": "2.10.0",
4440
"monaco-editor": "0.55.1",
45-
"monaco-editor-webpack-plugin": "7.1.1",
4641
"online-3d-viewer": "0.18.0",
4742
"pdfobject": "2.3.1",
4843
"perfect-debounce": "2.1.0",
4944
"postcss": "8.5.8",
50-
"postcss-loader": "8.2.1",
45+
"rollup-plugin-license": "3.7.0",
5146
"sortablejs": "1.15.7",
5247
"swagger-ui-dist": "5.32.0",
5348
"tailwindcss": "3.4.17",
@@ -57,12 +52,11 @@
5752
"tributejs": "5.1.3",
5853
"uint8-to-base64": "0.2.1",
5954
"vanilla-colorful": "0.7.2",
55+
"vite": "8.0.0",
56+
"vite-string-plugin": "2.0.2",
6057
"vue": "3.5.29",
6158
"vue-bar-graph": "2.2.0",
6259
"vue-chartjs": "5.3.3",
63-
"vue-loader": "17.4.2",
64-
"webpack": "5.105.4",
65-
"webpack-cli": "6.0.1",
6660
"wrap-ansi": "10.0.0"
6761
},
6862
"devDependencies": {
@@ -83,7 +77,6 @@
8377
"@types/throttle-debounce": "5.0.2",
8478
"@types/toastify-js": "1.12.4",
8579
"@typescript-eslint/parser": "8.56.1",
86-
"@vitejs/plugin-vue": "6.0.4",
8780
"@vitest/eslint-plugin": "1.6.9",
8881
"eslint": "9.39.2",
8982
"eslint-import-resolver-typescript": "4.4.4",
@@ -114,8 +107,7 @@
114107
"typescript": "5.9.3",
115108
"typescript-eslint": "8.56.1",
116109
"updates": "17.8.3",
117-
"vite-string-plugin": "2.0.1",
118-
"vitest": "4.0.18",
110+
"vitest": "4.1.0",
119111
"vue-tsc": "3.2.5"
120112
},
121113
"pnpm": {

0 commit comments

Comments
 (0)