Skip to content

Commit e87048f

Browse files
committed
create "make dev" recipe
1 parent 5c3513f commit e87048f

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,15 @@ It has a corresponding `.meta.js` so updates will work automatically.
1717

1818
## Development
1919

20+
We use `esbuild` for development and production builds.
21+
2022
### Method A
2123

22-
This has only been tested with `Tampermonkey > Settings > Security > Modify existing content security policy (CSP) headers` set to `Remove entirely (possibly unsecure)`. Use your favorite local http server (e.g., [python's http.server](https://github.com/avindra/dotfiles/blob/src/.local/bin/http)).
24+
Use `make dev` to spin up `esbuild`'s built-in HTTP server.
25+
26+
You will have to configure a CSP bypass for sites that define such policies (many do). This can be done via `Tampermonkey > Settings > Security > Modify existing content security policy (CSP) headers`. Set this option to `Remove entirely (possibly unsecure)`. Firefox and Chrome are both known to work.
27+
28+
Then, install the following script hook:
2329

2430
```js
2531
// ==UserScript==
@@ -35,8 +41,7 @@ import("http://localhost:5000/index.js");
3541

3642
### Method B
3743

38-
Run `make` to build the bundle. It requires `esbuild`. The script will go directly to your clipboard (assuming Wayland) using `wl-copy`. Then, paste the result into your userscript manager's editor. A less cumbersome method is desired, please suggest a better way if you know one!
39-
44+
Run `make snag` to build the bundle. The script will go directly to your clipboard (assuming Wayland) using `wl-copy`. Then, paste the result into your userscript manager's editor. Although this works, it is highly recommended to instead use `Method A` which is much more convenient to develop with.
4045

4146
## License
4247

makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
.PHONY: bundle snag
2-
.DEFAULT_GOAL := snag
1+
.PHONY: bundle snag dev
2+
.DEFAULT_GOAL := dev
3+
4+
PORT ?= 5000
5+
6+
dev:
7+
esbuild --servedir=. --serve=$(PORT) --cors-origin=*
38

49
bundle:
510
esbuild index.js --bundle --minify --outfile=useascript.user.js

0 commit comments

Comments
 (0)