diff options
author | silverwind <me@silverwind.io> | 2020-07-12 11:10:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-12 12:10:56 +0300 |
commit | 8188176b588264fe0ff8e3f82a623ea007a1af41 (patch) | |
tree | 0dd469b25f45c5a40ee62916b40162985753972a /Makefile | |
parent | 63591016b3ecd79ab1172cd98e2e830a09d6f515 (diff) | |
download | gitea-8188176b588264fe0ff8e3f82a623ea007a1af41.tar.gz gitea-8188176b588264fe0ff8e3f82a623ea007a1af41.zip |
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
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 23 |
1 files changed, 20 insertions, 3 deletions
@@ -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 |