esgleam
Types
Config for esbuild
pub type Config {
Config(
autoinstall: Bool,
outdir: String,
entry_points: List(String),
format: Format,
kind: Kind,
minify: Bool,
target: List(String),
serve: Option(String),
sourcemap: Bool,
platform: Option(Platform),
watch: Bool,
raw: String,
)
}
Constructors
-
Config( autoinstall: Bool, outdir: String, entry_points: List(String), format: Format, kind: Kind, minify: Bool, target: List(String), serve: Option(String), sourcemap: Bool, platform: Option(Platform), watch: Bool, raw: String, )Arguments
-
autoinstall
If true, automatically install esbuild if has not been installed (needs Erlang installed) default
True. -
outdir
Output directory
-
entry_points
List of entry points supplied
-
format
Output format for JavaScript. See
FormatdefaultEsm -
kind
Kind for output default
Library -
minify
default
False -
target
List of target environments default
[] -
serve
The root directory for the dev server (run server when defined) default
None -
sourcemap
Generate sourcemap for JavaScript default
False -
platform
Platform for the output See esbuild/platform for what each type does default
Neutral -
watch
Enable watchmode. Bundles files on change Note:
gleam buildneed to be run manually defaultFalse -
raw
raw flags to pass to esbuild default
""
-
Output format of generated JavaScript
pub type Format {
Esm
Cjs
Iife
}
Constructors
-
EsmECMAScript module
-
CjsCommonJS
-
Iifeimmediately-invoked function expression
Kind of output
pub type Kind {
Script
Library
}
Constructors
-
ScriptExecutes the
main()function in your entry point -
LibraryOnly exports the code
Functions
pub fn autoinstall(config: Config, do_install: Bool) -> Config
Boolean for autoinstalling esbuild if it is not found.
If True, requires erlang to be install on the system.
pub fn bundle(config: Config) -> Result(Nil, FileError)
Executes esbuild with the provided config parsed as CLI arguments.
pub fn entry(config: Config, path: String) -> Config
Entry points Can be use multiple times
pub fn kind(config: Config, kind: Kind) -> Config
Kind for output. see Kind
if set to Script, will ignore all entries except the first and will call its main function.
pub fn new(outdir path: String) -> Config
Start to create a build script
> esbuild.new("./dist/static")
Config("./dist/static", ...)
pub fn platform(
config: Config,
platform platform: Platform,
) -> Config
Generate code for a specified platform
pub fn serve(config: Config, dir path: String) -> Config
Start a development server on http://127.0.0.1:8000 with path being /
pub fn target(config: Config, target: String) -> Config
Target for transpiled JavaScript. Can be used mutiple times
> esbuild.new("./dist/static")
> |> esbuild.target("es2020")
> |> esbuild.target("firefox110")
> |> esbuild.target("edge90")
pub fn watch(config: Config, do_watch: Bool) -> Config
Note: There is no file watcher for Gleam files so you have to manually run gleam build on change.
pub fn watch_gleam() -> fn() -> Nil