Skip to content

add 'make watch-frontend' and expand docs #10931

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ help:
@echo " - lint lint everything"
@echo " - lint-frontend lint frontend files"
@echo " - lint-backend lint backend files"
@echo " - watch-frontend watch frontend files and continuously rebuild"
@echo " - webpack build webpack files"
@echo " - fomantic build fomantic files"
@echo " - generate run \"go generate\""
Expand Down Expand Up @@ -275,6 +276,10 @@ lint-frontend: node_modules
npx eslint web_src/js webpack.config.js
npx stylelint web_src/less

.PHONY: watch-frontend
watch-frontend: node_modules
NODE_ENV=development npx webpack --hide-modules --display-entrypoints=false --watch

.PHONY: test
test:
$(GO) test $(GOTESTFLAGS) -mod=vendor -tags='sqlite sqlite_unlock_notify' $(GO_PACKAGES)
Expand Down
22 changes: 20 additions & 2 deletions docs/content/doc/advanced/hacking-on-gitea.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,28 @@ make revive vet misspell-check

### Working on JS and CSS

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

```bash
make webpack
make build && ./gitea
```

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:

```bash
make backend && ./gitea
```

With the backend running, open another terminal and run:

```bash
make watch-frontend
```

Before committing, make sure the linters pass:

```bash
make lint-frontend
```

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.
Expand Down