Skip to content

Commit eaf9ded

Browse files
jolheiserzeripath
authored andcommitted
Makefile changes for Windows and easier development (#6103)
* Added Go Path and node_modules to PATH * Uses npx now for generate-stylesheets * Uses `go env GOPATH` to calculate adding GOPATH/bin to PATH * Added note about installing Node 8.0+ to generate stylesheets * Added preferred Node version to CONTRIBUTING.md
1 parent eea1155 commit eaf9ded

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ included in the next released version.
102102
Generally, the go build tools are installed as-needed in the `Makefile`.
103103
An exception are the tools to build the CSS and images.
104104

105-
- To build CSS: Install [Node.js](https://nodejs.org/en/download/package-manager)
105+
- To build CSS: Install [Node.js](https://nodejs.org/en/download/package-manager) at version 8.0 or above
106106
with `npm` and then run `npm install` and `make generate-stylesheets`.
107107
- To build Images: ImageMagick, inkscape and zopflipng binaries must be
108108
available in your `PATH` to run `make generate-images`.

Makefile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ IMPORT := code.gitea.io/gitea
44
GO ?= go
55
SED_INPLACE := sed -i
66

7+
export PATH := $($(GO) env GOPATH)/bin:$(PATH)
8+
79
ifeq ($(OS), Windows_NT)
810
EXECUTABLE := gitea.exe
911
else
@@ -365,10 +367,14 @@ stylesheets-check: generate-stylesheets
365367

366368
.PHONY: generate-stylesheets
367369
generate-stylesheets:
370+
@hash npx > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
371+
echo "Please install npm version 5.2+"; \
372+
exit 1; \
373+
fi;
368374
$(eval BROWSERS := "> 2%, last 2 firefox versions, last 2 safari versions")
369-
node_modules/.bin/lessc --clean-css public/less/index.less public/css/index.css
370-
$(foreach file, $(filter-out public/less/themes/_base.less, $(wildcard public/less/themes/*)),node_modules/.bin/lessc --clean-css public/less/themes/$(notdir $(file)) > public/css/theme-$(notdir $(call strip-suffix,$(file))).css;)
371-
$(foreach file, $(wildcard public/css/*),node_modules/.bin/postcss --use autoprefixer --autoprefixer.browsers $(BROWSERS) -o $(file) $(file);)
375+
npx lessc --clean-css public/less/index.less public/css/index.css
376+
$(foreach file, $(filter-out public/less/themes/_base.less, $(wildcard public/less/themes/*)),npx lessc --clean-css public/less/themes/$(notdir $(file)) > public/css/theme-$(notdir $(call strip-suffix,$(file))).css;)
377+
$(foreach file, $(wildcard public/css/*),npx postcss --use autoprefixer --autoprefixer.browsers $(BROWSERS) -o $(file) $(file);)
372378

373379
.PHONY: swagger-ui
374380
swagger-ui:

docs/content/doc/advanced/hacking-on-gitea.en-us.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ make vet lint misspell-check
138138

139139
### Updating the stylesheets
140140

141+
To generate the stylsheets, you will need [Node.js](https://nodejs.org/) at version 8.0 or above.
142+
141143
At present we use [less](http://lesscss.org/) and [postcss](https://postcss.org) to generate our stylesheets. Do
142144
**not** edit the files in `public/css/` directly as they are generated from
143145
`lessc` from the files in `public/less/`.

0 commit comments

Comments
 (0)