Direct SVG rendering (#12157)

Introduce 'make svg' which calls a node script that compiles svg files
to `public/img/svg`. These files are vendored to not create a dependency
on Node for the backend build.

On the frontend side, configure webpack using `raw-loader` so SVGs can
be imported as string.

Also moved our existing SVGs to web_src/svg for consistency.

Fixes: https://github.com/go-gitea/gitea/issues/11618
This commit is contained in:
silverwind 2020-07-12 11:10:56 +02:00 committed by GitHub
parent 63591016b3
commit 8188176b58
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
227 changed files with 452 additions and 609 deletions

View file

@ -95,11 +95,13 @@ FOMANTIC_DEST_DIR := web_src/fomantic/build
WEBPACK_SOURCES := $(shell find web_src/js web_src/less -type f) $(FOMANTIC_DEST)
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/serviceworker.js public/img/svg
WEBPACK_DEST_ENTRIES := public/js public/css public/fonts public/serviceworker.js
BINDATA_DEST := modules/public/bindata.go modules/options/bindata.go modules/templates/bindata.go
BINDATA_HASH := $(addsuffix .hash,$(BINDATA_DEST))
SVG_DEST_DIR := public/img/svg
TAGS ?=
TAGS_SPLIT := $(subst $(COMMA), ,$(TAGS))
TAGS_EVIDENCE := $(MAKE_EVIDENCE_DIR)/tags
@ -158,6 +160,7 @@ help:
@echo " - lint-backend lint backend files"
@echo " - watch-frontend watch frontend files and continuously rebuild"
@echo " - webpack build webpack files"
@echo " - svg build svg files"
@echo " - fomantic build fomantic files"
@echo " - generate run \"go generate\""
@echo " - fmt format the Go code"
@ -292,8 +295,8 @@ lint: lint-backend lint-frontend
lint-backend: golangci-lint revive vet swagger-check swagger-validate test-vendor
.PHONY: lint-frontend
lint-frontend: node_modules
npx eslint web_src/js webpack.config.js
lint-frontend: node_modules svg-check
npx eslint web_src/js build webpack.config.js
npx stylelint web_src/less
.PHONY: watch-frontend
@ -605,6 +608,20 @@ $(WEBPACK_DEST): $(WEBPACK_SOURCES) $(WEBPACK_CONFIGS) package-lock.json | node_
npx webpack --hide-modules --display-entrypoints=false
@touch $(WEBPACK_DEST)
.PHONY: svg
svg: node-check | node_modules
rm -rf $(SVG_DEST_DIR)
node build/generate-svg.js
.PHONY: svg-check
svg-check: svg
@diff=$$(git diff $(SVG_DEST_DIR)); \
if [ -n "$$diff" ]; then \
echo "Please run 'make svg' and commit the result:"; \
echo "$${diff}"; \
exit 1; \
fi;
.PHONY: update-translations
update-translations:
mkdir -p ./translations