I have been trying to get my wasm app running on my Hugo site for the past week, and have run into a dead end.
After building everything with webpack
, my dist
directory looks like this:
project/dist ❯ ls
0.bootstrap.js bootstrap.js index.html
2d159acca5a4d5967245.module.wasm bundle.js
4ac1e69088fb0b58205f.module.wasm effbba6233883be097ea.module.wasm
index.html
loads bootstrap.js
like this:
<script src="bootstrap.js"></script>
Everything works perfectly if I run python -m http.server
in project/dist
. All I want is to be able to call the functions defined in the wasm from a hugo page.
First, I copied index.html to layouts/shortcodes/game_2048.html
so I can add it to an article.
I then copied everything in the original dist
directory to assets/solve2048_dist
and referenced the js file in solve_2048.html
like so
{{ $js_2048 := resources.Get "js/solve2048_dist/bootstrap.js" }}
<script src="{{ $js_2048.Permalink }}"></script>
When I run the hugo server, I get 404
errors whenever bootstrap.js
imports 0.bootstrap.js
or the wasm
files. Piping to the js.Build
template function does not work either.
It seems like hugo just needs to make the js/solve2048_dist/*
files available to the fetch
API, but I might be missing something.
Any pointers are appreciated. Thank you.