Skip to content

Commit cc4da79

Browse files
add 'make watch-frontend' and expand docs (#10931)
* add 'make watch-frontend' and expand docs * add bindata note * add .PHONY Co-authored-by: guillep2k <[email protected]>
1 parent 59c31b4 commit cc4da79

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ help:
136136
@echo " - lint lint everything"
137137
@echo " - lint-frontend lint frontend files"
138138
@echo " - lint-backend lint backend files"
139+
@echo " - watch-frontend watch frontend files and continuously rebuild"
139140
@echo " - webpack build webpack files"
140141
@echo " - fomantic build fomantic files"
141142
@echo " - generate run \"go generate\""
@@ -275,6 +276,10 @@ lint-frontend: node_modules
275276
npx eslint web_src/js webpack.config.js
276277
npx stylelint web_src/less
277278

279+
.PHONY: watch-frontend
280+
watch-frontend: node_modules
281+
NODE_ENV=development npx webpack --hide-modules --display-entrypoints=false --watch
282+
278283
.PHONY: test
279284
test:
280285
$(GO) test $(GOTESTFLAGS) -mod=vendor -tags='sqlite sqlite_unlock_notify' $(GO_PACKAGES)

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,28 @@ make revive vet misspell-check
128128

129129
### Working on JS and CSS
130130

131-
Edit files in `web_src` and run the linter and build the files in `public`:
131+
For simple changes, edit files in `web_src`, run the build and start the server to test:
132132

133133
```bash
134-
make webpack
134+
make build && ./gitea
135+
```
136+
137+
For more involved changes use the `watch-frontend` task to continuously rebuild files when their sources change. The `bindata` tag must be absent to ensure the file system will be used for files in `public`. First, build and run the backend:
138+
139+
```bash
140+
make backend && ./gitea
141+
```
142+
143+
With the backend running, open another terminal and run:
144+
145+
```bash
146+
make watch-frontend
147+
```
148+
149+
Before committing, make sure the linters pass:
150+
151+
```bash
152+
make lint-frontend
135153
```
136154

137155
Note: When working on frontend code, it is advisable to set `USE_SERVICE_WORKER` to `false` in `app.ini` which will prevent undesirable caching of frontend assets.

0 commit comments

Comments
 (0)