eleventy and esbuild

This commit is contained in:
SArpnt 2023-12-22 21:46:48 -05:00
parent fed9adcaec
commit 687c171d55
Signed by: SArpnt
SSH key fingerprint: SHA256:wyRI40FXp6te9QA9r2OFJf+DtCZQmqZFNTj7EV6aMDA
155 changed files with 1500 additions and 81 deletions

2
.gitignore vendored
View file

@ -1,3 +1,3 @@
/node_modules
/build/*
/_site
**/rust/target

4
.prettierrc.json5 Normal file
View file

@ -0,0 +1,4 @@
{
useTabs: true,
arrowParens: "avoid",
}

View file

@ -1,63 +0,0 @@
http_server = python -m "http.server" -d build $(port)
zola_serve_options = -p $(port)
port = 8080
esbuild_files := src/style.css src/bytebeat.js src/embed.js src/audio-worklet.js
watch_files := src config.toml templates content static
check_programs = $(foreach exec,$(1),$(if $(shell which $(exec) 2> /dev/null),,$(error "No $(exec) in PATH")))
onexit = (while kill -0 $$PPID 2> /dev/null; do sleep .5; done; $(1)) &
job = & echo $$!; $(call onexit,kill $$!)
# TODO: set build dir, note that it would require removing whatever other directory instead
.PHONY: build
build: clean
$(call check_programs, zola esbuild)
zola build
esbuild --format=esm --minify --sourcemap --bundle --splitting --outdir=build $(esbuild_files)
# TODO: set build dir, default tmpdir
.PHONY: serve
serve:
$(call check_programs,inotifywait $(word 1,$(http_server)))
$(MAKE) build
$(http_server) $(job)
while true; do \
inotifywait $(watch_files);\
$(MAKE) build;\
done
cd $(build_tempdir)/zola && zola build
rm -r $(build_tempdir)
# it's a good idea but doesn't work because of zola bugs
.PHONY: serve2
serve2:
$(call check_programs, zola esbuild inotifywait $(word 1,$(http_server)))
$(eval build_tempdir := $(shell mktemp -d)))
$(call onexit, rm -r $(build_tempdir))
mkdir $(build_tempdir)/esbuild
mkdir $(build_tempdir)/zola
cp -rsL $(shell pwd)/config.toml $(build_tempdir)/zola
cp -rsL $(shell pwd)/templates $(build_tempdir)/zola
cp -rsL $(shell pwd)/content $(build_tempdir)/zola
build_tempdir=$(build_tempdir) $(MAKE) _update_serve2;\
cd $(build_tempdir)/zola; zola serve $(zola_serve_options) $(job)
while true; do \
inotifywait src;\
build_tempdir=$(build_tempdir) $(MAKE) _update_serve2;\
done
.PHONY: _update_serve2
_update_serve2:
esbuild --format=esm --minify --sourcemap --bundle --splitting --outdir=$(build_tempdir)/esbuild $(esbuild_files)
rm -r $(build_tempdir)/zola/static
mkdir $(build_tempdir)/zola/static
cp -rsL $(shell pwd)/static/. $(build_tempdir)/zola/static
cp -rsL $(build_tempdir)/esbuild/. $(build_tempdir)/zola/static
.PHONY: clean
clean:
-rm -r build

View file

@ -97,10 +97,17 @@ note that the license has changed from MIT to AGPL, the different versions have
(not legal advice)
if the agpl isn't clear enough, putting the website in an iframe doesn't require you to use AGPL for the website it's in.
if the AGPL isn't clear enough, putting the website in an iframe doesn't require you to use AGPL for the website it's in.
if you were to modify the website AND put it online, then you would have to make it AGPL.
## building
- install [zola](getzola.org) and [esbuild](esbuild.github.io)
- run `./build.sh`
install pnpm (although npm or similar probably works fine too)
```sh
pnpm i
pnpm run
```
view the scripts and run what you need.
build will create the webpage files, serve will let you view the webpage easily.

View file

Before

Width:  |  Height:  |  Size: 596 B

After

Width:  |  Height:  |  Size: 596 B

Some files were not shown because too many files have changed in this diff Show more