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: https://github.com/go-gitea/gitea/issues/10569
Fixes: https://github.com/go-gitea/gitea/issues/10565
Fixes: https://github.com/go-gitea/gitea/issues/10570
Fixes: https://github.com/go-gitea/gitea/issues/10568
release/v1.15
silverwind 2020-03-03 20:51:11 +01:00 committed by GitHub
parent aa4a297c16
commit fa6ea60c55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 13 deletions

View File

@ -19,7 +19,7 @@ WORKDIR ${GOPATH}/src/code.gitea.io/gitea
#Checkout version if set #Checkout version if set
RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \ RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \
&& make clean build && make clean-all build
FROM alpine:3.11 FROM alpine:3.11
LABEL maintainer="maintainers@gitea.io" LABEL maintainer="maintainers@gitea.io"

View File

@ -21,6 +21,7 @@ else
EXECUTABLE ?= gitea EXECUTABLE ?= gitea
UNAME_S := $(shell uname -s) UNAME_S := $(shell uname -s)
FIND_PWD_REGEXP := find . -regextype posix-egrep FIND_PWD_REGEXP := find . -regextype posix-egrep
BUSYBOX := $(shell find --help 2>&1 | grep -o BusyBox)
ifeq ($(UNAME_S),Darwin) ifeq ($(UNAME_S),Darwin)
SED_INPLACE := sed -i '' SED_INPLACE := sed -i ''
FIND_PWD_REGEXP := find -E . FIND_PWD_REGEXP := find -E .
@ -29,6 +30,9 @@ else
SED_INPLACE := sed -i '' SED_INPLACE := sed -i ''
FIND_PWD_REGEXP := find -E . FIND_PWD_REGEXP := find -E .
endif endif
ifeq ($(BUSYBOX),BusyBox)
FIND_PWD_REGEXP := find .
endif
endif endif
GOFMT ?= gofmt -s GOFMT ?= gofmt -s
@ -70,18 +74,17 @@ PACKAGES ?= $(filter-out code.gitea.io/gitea/integrations/migration-test,$(filte
GO_SOURCES ?= $(shell $(FIND_PWD_REGEXP) -regex '\./(node_modules|docs|public|options|contrib|data)' -prune -o -name "*.go" -type f -print) GO_SOURCES ?= $(shell $(FIND_PWD_REGEXP) -regex '\./(node_modules|docs|public|options|contrib|data)' -prune -o -name "*.go" -type f -print)
GO_SOURCES_OWN := $(filter-out ./vendor/% %/bindata.go, $(GO_SOURCES)) GO_SOURCES_OWN := $(filter-out ./vendor/% %/bindata.go, $(GO_SOURCES))
WEBPACK_SOURCES ?= $(shell find web_src/js web_src/less -type f) WEBPACK_SOURCES := $(shell find web_src/js web_src/less -type f)
WEBPACK_CONFIGS := webpack.config.js .eslintrc .stylelintrc WEBPACK_CONFIGS := webpack.config.js .eslintrc .stylelintrc
WEBPACK_DEST := public/js/index.js public/css/index.css WEBPACK_DEST := public/js/index.js public/css/index.css
WEBPACK_DEST_DIRS := public/js public/css
BINDATA_DEST := modules/public/bindata.go modules/options/bindata.go modules/templates/bindata.go BINDATA_DEST := modules/public/bindata.go modules/options/bindata.go modules/templates/bindata.go
BINDATA_HASH := $(addsuffix .hash,$(BINDATA_DEST)) BINDATA_HASH := $(addsuffix .hash,$(BINDATA_DEST))
WEBPACK_DEST_DIRS := public/js public/css FOMANTIC_CONFIGS := semantic.json web_src/fomantic/theme.config.less web_src/fomantic/_site/globals/site.variables
FOMANTIC_DEST := public/fomantic/semantic.min.js public/fomantic/semantic.min.css
FOMANTIC_SOURCES ?= web_src/fomantic/theme.config.less web_src/fomantic/_site/globals/site.variables
FOMANTIC_DEST_DIR := public/fomantic FOMANTIC_DEST_DIR := public/fomantic
FOMANTIC_EVIDENCE := $(MAKE_EVIDENCE_DIR)/fomantic
TAGS ?= TAGS ?=
TAGS_EVIDENCE := $(MAKE_EVIDENCE_DIR)/tags TAGS_EVIDENCE := $(MAKE_EVIDENCE_DIR)/tags
@ -164,7 +167,7 @@ node-check:
.PHONY: clean-all .PHONY: clean-all
clean-all: clean clean-all: clean
rm -rf $(WEBPACK_DEST_DIRS) $(FOMANTIC_DEST_DIR) $(FOMANTIC_EVIDENCE) rm -rf $(WEBPACK_DEST_DIRS) $(FOMANTIC_DEST_DIR)
.PHONY: clean .PHONY: clean
clean: clean:
@ -453,7 +456,7 @@ install: $(wildcard *.go)
build: frontend backend build: frontend backend
.PHONY: frontend .PHONY: frontend
frontend: node-check $(FOMANTIC_EVIDENCE) $(WEBPACK_DEST) frontend: node-check $(FOMANTIC_DEST) $(WEBPACK_DEST)
.PHONY: backend .PHONY: backend
backend: go-check generate $(EXECUTABLE) backend: go-check generate $(EXECUTABLE)
@ -543,18 +546,19 @@ css:
$(MAKE) webpack $(MAKE) webpack
.PHONY: fomantic .PHONY: fomantic
fomantic: $(FOMANTIC_EVIDENCE) fomantic: $(FOMANTIC_DEST)
$(FOMANTIC_EVIDENCE): semantic.json $(FOMANTIC_SOURCES) | node_modules $(FOMANTIC_DEST): $(FOMANTIC_CONFIGS) package-lock.json | node_modules
rm -rf $(FOMANTIC_DEST_DIR)
cp web_src/fomantic/theme.config.less node_modules/fomantic-ui/src/theme.config cp web_src/fomantic/theme.config.less node_modules/fomantic-ui/src/theme.config
cp web_src/fomantic/_site/globals/* node_modules/fomantic-ui/src/_site/globals/ cp web_src/fomantic/_site/globals/* node_modules/fomantic-ui/src/_site/globals/
npx gulp -f node_modules/fomantic-ui/gulpfile.js build npx gulp -f node_modules/fomantic-ui/gulpfile.js build
@mkdir -p $(MAKE_EVIDENCE_DIR) && touch $(FOMANTIC_EVIDENCE) @touch $(FOMANTIC_DEST)
.PHONY: webpack .PHONY: webpack
webpack: $(WEBPACK_DEST) webpack: $(WEBPACK_DEST)
$(WEBPACK_DEST): $(WEBPACK_SOURCES) $(WEBPACK_CONFIGS) | node_modules $(WEBPACK_DEST): $(WEBPACK_SOURCES) $(WEBPACK_CONFIGS) package-lock.json | node_modules
npx eslint web_src/js webpack.config.js npx eslint web_src/js webpack.config.js
npx stylelint web_src/less npx stylelint web_src/less
npx webpack --hide-modules --display-entrypoints=false npx webpack --hide-modules --display-entrypoints=false