Skip to content

Build frontend with Vite #25874

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ cpu.out
/public/js
/public/css
/public/fonts
/public/img/webpack
/public/img/bundled
/vendor
/web_src/fomantic/node_modules
/web_src/fomantic/build/*
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ cpu.out
/public/js
/public/css
/public/fonts
/public/img/webpack
/public/img/bundled
/vendor
/web_src/fomantic/node_modules
/web_src/fomantic/build/*
Expand Down
30 changes: 15 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ GO_TEST_PACKAGES ?= $(filter-out $(shell $(GO) list code.gitea.io/gitea/models/m

FOMANTIC_WORK_DIR := web_src/fomantic

WEBPACK_SOURCES := $(shell find web_src/js web_src/css -type f)
WEBPACK_CONFIGS := webpack.config.js
WEBPACK_DEST := public/js/index.js public/css/index.css
WEBPACK_DEST_ENTRIES := public/js public/css public/fonts public/img/webpack
VITE_SOURCES := $(shell find web_src/js web_src/css -type f)
VITE_CONFIGS := vite.config.js
VITE_DEST := public/js/index.js public/css/index.css
VITE_DEST_ENTRIES := public/js public/css public/fonts public/img/bundled

BINDATA_DEST := modules/public/bindata.go modules/options/bindata.go modules/templates/bindata.go
BINDATA_HASH := $(addsuffix .hash,$(BINDATA_DEST))
Expand Down Expand Up @@ -228,7 +228,7 @@ help:
@echo " - test-e2e[\#TestSpecificName] test end to end using playwright"
@echo " - update-js update js dependencies"
@echo " - update-py update py dependencies"
@echo " - webpack build webpack files"
@echo " - vite build vite files"
@echo " - svg build svg files"
@echo " - fomantic build fomantic files"
@echo " - generate run \"go generate\""
Expand Down Expand Up @@ -273,7 +273,7 @@ node-check:

.PHONY: clean-all
clean-all: clean
rm -rf $(WEBPACK_DEST_ENTRIES) node_modules
rm -rf $(VITE_DEST_ENTRIES) node_modules

.PHONY: clean
clean:
Expand Down Expand Up @@ -434,8 +434,8 @@ watch:

.PHONY: watch-frontend
watch-frontend: node-check node_modules
@rm -rf $(WEBPACK_DEST_ENTRIES)
NODE_ENV=development npx webpack --watch --progress
@rm -rf $(VITE_DEST_ENTRIES)
NODE_ENV=development npx vite build --watch

.PHONY: watch-backend
watch-backend: go-check
Expand Down Expand Up @@ -806,7 +806,7 @@ install: $(wildcard *.go)
build: frontend backend

.PHONY: frontend
frontend: $(WEBPACK_DEST)
frontend: $(VITE_DEST)

.PHONY: backend
backend: go-check generate-backend $(EXECUTABLE)
Expand Down Expand Up @@ -952,14 +952,14 @@ fomantic:
$(SED_INPLACE) -e 's/\r//g' $(FOMANTIC_WORK_DIR)/build/semantic.css $(FOMANTIC_WORK_DIR)/build/semantic.js
rm -f $(FOMANTIC_WORK_DIR)/build/*.min.*

.PHONY: webpack
webpack: $(WEBPACK_DEST)
.PHONY: vite
vite: $(VITE_DEST)

$(WEBPACK_DEST): $(WEBPACK_SOURCES) $(WEBPACK_CONFIGS) package-lock.json
$(VITE_DEST): $(VITE_SOURCES) $(VITE_CONFIGS) package-lock.json
@$(MAKE) -s node-check node_modules
rm -rf $(WEBPACK_DEST_ENTRIES)
npx webpack
@touch $(WEBPACK_DEST)
rm -rf $(VITE_DEST_ENTRIES)
npx vite build
@touch $(VITE_DEST)

.PHONY: svg
svg: node-check | node_modules
Expand Down
Loading