esbuild for Gleam that works on Erlang & JavaScript.
Create a Gleam project as you would normally and make sure you have a file in src
with the name of your project (as specified in gleam.toml
)
Install esbuild
gleam run -m esgleam/install
gleam run -m esgleam/bundle
See /dist
for your bundled code
To start a development server
gleam run -m esgleam/serve
(Follow steps 1-2)
/src/build.gleam
with the following
import esgleam
pub fn main() { esgleam.new("./dist/static") |> esgleam.entry("main.gleam") |> esgleam.bundle }
See [esgleam](https://hexdocs.pm/esgleam/esgleam.html) for all config options and their default values.
5. Run your build script
```sh
gleam run -m build
Install esbuild.
gleam run -m esgleam/install
Bundle the project into a library with src/{project_name}.gleam
as your entry point and ./dist/{project_name}.js
as your output file.
gleam run -m esgleam/bundle
Bundle the project into a single file to run with src/{project_name}.gleam
as your entry point and ./dist/{project_name}.js
as your output file.
Similar to just running gleam run
.
gleam run -m esgleam/app
Starts a dev server, serving the dist
directory as /
.
gleam run -m esgleam/serve
If available on Hex this package can be added to your Gleam project:
gleam add esgleam
and its documentation can be found at https://hexdocs.pm/esgleam.
*.gleam
which runs on both Erlang and JavaScriptesbuild
in the erlang target