Skip to content

Commit fa6ea60

Browse files
authored
Frontend build improvements, fix Fomantic build (#10576)
- add package-lock.json to webpack/fomantic prereqs making them always rebuild when dependencies change. - remove FOMANTIC_EVIDENCE. It seemed better to just track a few output files instead. - delete fomantic output files before build to prevent possible bugs in fomantic's build. - resolve WEBPACK_SOURCES only once for performance - reorder variables for clarity - use clean-all in Dockerfile - detect busybox for find syntax Fixes: #10569 Fixes: #10565 Fixes: #10570 Fixes: #10568
1 parent aa4a297 commit fa6ea60

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ WORKDIR ${GOPATH}/src/code.gitea.io/gitea
1919

2020
#Checkout version if set
2121
RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \
22-
&& make clean build
22+
&& make clean-all build
2323

2424
FROM alpine:3.11
2525
LABEL maintainer="[email protected]"

Makefile

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ else
2121
EXECUTABLE ?= gitea
2222
UNAME_S := $(shell uname -s)
2323
FIND_PWD_REGEXP := find . -regextype posix-egrep
24+
BUSYBOX := $(shell find --help 2>&1 | grep -o BusyBox)
2425
ifeq ($(UNAME_S),Darwin)
2526
SED_INPLACE := sed -i ''
2627
FIND_PWD_REGEXP := find -E .
@@ -29,6 +30,9 @@ else
2930
SED_INPLACE := sed -i ''
3031
FIND_PWD_REGEXP := find -E .
3132
endif
33+
ifeq ($(BUSYBOX),BusyBox)
34+
FIND_PWD_REGEXP := find .
35+
endif
3236
endif
3337

3438
GOFMT ?= gofmt -s
@@ -70,18 +74,17 @@ PACKAGES ?= $(filter-out code.gitea.io/gitea/integrations/migration-test,$(filte
7074
GO_SOURCES ?= $(shell $(FIND_PWD_REGEXP) -regex '\./(node_modules|docs|public|options|contrib|data)' -prune -o -name "*.go" -type f -print)
7175
GO_SOURCES_OWN := $(filter-out ./vendor/% %/bindata.go, $(GO_SOURCES))
7276

73-
WEBPACK_SOURCES ?= $(shell find web_src/js web_src/less -type f)
77+
WEBPACK_SOURCES := $(shell find web_src/js web_src/less -type f)
7478
WEBPACK_CONFIGS := webpack.config.js .eslintrc .stylelintrc
75-
7679
WEBPACK_DEST := public/js/index.js public/css/index.css
80+
WEBPACK_DEST_DIRS := public/js public/css
81+
7782
BINDATA_DEST := modules/public/bindata.go modules/options/bindata.go modules/templates/bindata.go
7883
BINDATA_HASH := $(addsuffix .hash,$(BINDATA_DEST))
7984

80-
WEBPACK_DEST_DIRS := public/js public/css
81-
82-
FOMANTIC_SOURCES ?= web_src/fomantic/theme.config.less web_src/fomantic/_site/globals/site.variables
85+
FOMANTIC_CONFIGS := semantic.json web_src/fomantic/theme.config.less web_src/fomantic/_site/globals/site.variables
86+
FOMANTIC_DEST := public/fomantic/semantic.min.js public/fomantic/semantic.min.css
8387
FOMANTIC_DEST_DIR := public/fomantic
84-
FOMANTIC_EVIDENCE := $(MAKE_EVIDENCE_DIR)/fomantic
8588

8689
TAGS ?=
8790
TAGS_EVIDENCE := $(MAKE_EVIDENCE_DIR)/tags
@@ -164,7 +167,7 @@ node-check:
164167

165168
.PHONY: clean-all
166169
clean-all: clean
167-
rm -rf $(WEBPACK_DEST_DIRS) $(FOMANTIC_DEST_DIR) $(FOMANTIC_EVIDENCE)
170+
rm -rf $(WEBPACK_DEST_DIRS) $(FOMANTIC_DEST_DIR)
168171

169172
.PHONY: clean
170173
clean:
@@ -453,7 +456,7 @@ install: $(wildcard *.go)
453456
build: frontend backend
454457

455458
.PHONY: frontend
456-
frontend: node-check $(FOMANTIC_EVIDENCE) $(WEBPACK_DEST)
459+
frontend: node-check $(FOMANTIC_DEST) $(WEBPACK_DEST)
457460

458461
.PHONY: backend
459462
backend: go-check generate $(EXECUTABLE)
@@ -543,18 +546,19 @@ css:
543546
$(MAKE) webpack
544547

545548
.PHONY: fomantic
546-
fomantic: $(FOMANTIC_EVIDENCE)
549+
fomantic: $(FOMANTIC_DEST)
547550

548-
$(FOMANTIC_EVIDENCE): semantic.json $(FOMANTIC_SOURCES) | node_modules
551+
$(FOMANTIC_DEST): $(FOMANTIC_CONFIGS) package-lock.json | node_modules
552+
rm -rf $(FOMANTIC_DEST_DIR)
549553
cp web_src/fomantic/theme.config.less node_modules/fomantic-ui/src/theme.config
550554
cp web_src/fomantic/_site/globals/* node_modules/fomantic-ui/src/_site/globals/
551555
npx gulp -f node_modules/fomantic-ui/gulpfile.js build
552-
@mkdir -p $(MAKE_EVIDENCE_DIR) && touch $(FOMANTIC_EVIDENCE)
556+
@touch $(FOMANTIC_DEST)
553557

554558
.PHONY: webpack
555559
webpack: $(WEBPACK_DEST)
556560

557-
$(WEBPACK_DEST): $(WEBPACK_SOURCES) $(WEBPACK_CONFIGS) | node_modules
561+
$(WEBPACK_DEST): $(WEBPACK_SOURCES) $(WEBPACK_CONFIGS) package-lock.json | node_modules
558562
npx eslint web_src/js webpack.config.js
559563
npx stylelint web_src/less
560564
npx webpack --hide-modules --display-entrypoints=false

0 commit comments

Comments
 (0)