Closed johannesvollmer closed 1 month ago
Gleam doesn't bundle JavaScript itself so you have two options:
build/dev/javascript
directory.You might find this blog post helpful. You might also want to ask on the gleam discord server, there are folks I know there that are using vite or other tools instead of lustre's dev tools and they may be able to help too :)
The absolute simplest thing you can do right now to get something on the screen is to:
create an index.html
in the root of your project
<!doctype html>
<html>
<head>
<script type="module">
import { main } from './build/dev/javascript/{name_of_your_app}/{name_of_your_app}.mjs'
document.addEventListener("DOMContentLoaded", () => {
main();
});
</script>
</head>
<body>
<div id="app"></div>
</body>
</html>
lustre.start
is "#app"
gleam build
in your terminalnpx http-server
(you mentioned in another issue that you have node so im assuming this is possible)this will get something showing in the browser at least :)
Thank you for your help and for taking the time. The blog post looks very valuable, and the code snippet looks delightfully simple.
For simple projects, not caring about old browsers or any optimization, would you recommend this simple setup, or would you not recommend this approach?
Would you accept a contributions to the lustre documentation concerning this approach?
Not right now, I don't have the bandwidth to make sure instructions like these are up-to-date or support users that get stuck taking that approach.
I'd like to encourage the community to write more blog posts and tutorials covering things like this, and over time I will come up with a way to surface them so other folks can find them. I own the lustre.build
domain and am slowly working on a site that will feature community packages and blog posts.
Thank you again :) Cheers
Hi! Is there a simple way to launch a lustre app without using the lustre_dev_tools? (It seems to require Erlang.) Is there a way to include the compiler output in an HTML file? Sorry if this is a beginner question, I'm just starting out.