Skip to content

Web toolchain

Run JavaScript and TypeScript with Elide, serve files during development, process web assets, install npm packages and configure web builds in elide.pkl.

On this page

Run, serve, build and install dependencies for JavaScript and TypeScript projects.

Run JavaScript and TypeScript

Terminal
bash
elide run app.js
elide run app.ts

TypeScript types are stripped. .mjs, .cjs, .mts and .cts also work.

Serve and develop

Terminal
bash
elide serve dist   # serve a directory on 127.0.0.1:8080
elide dev public   # dev server on 127.0.0.1:3000; pages reload when files change
Running the Elide development server and reloading a changed page
 ~/demo  elide dev site --no-tui --port 43765 &
Dev server for directory: "site"
Dev server: site at http://127.0.0.1:43765
 ~/demo  curl -s http://127.0.0.1:43765 | head -2
GET / 200 (164us)
<!doctype html>
<h1>Hello, Ada!</h1>
 ~/demo  sed -i.bak 's/Ada/Grace/' site/index.html
[watch] Create /home/demo/demo/site/sedsHkWQG
 ~/demo  curl -s http://127.0.0.1:43765 | head -2
GET / 200 (112us)
<!doctype html>
<h1>Hello, Grace!</h1>
 

Page reload applies to directories, not to a script passed to elide dev. --host and --port set the address, --no-watch turns off watching, and --no-tui prints plain logs. More, including --contexts: Development Server.

Process assets

No manifest needed:

Terminal
bash
elide web build app.ts --out dist     # JavaScript
elide web build page.md --out dist    # HTML
elide web build style.css --out dist  # CSS

Several sources and shell globs are accepted.

Install npm packages

Terminal
bash
elide install --ecosystems=npm

See NPM Installer.

Manifest settings

pkl
web {
  minifyHtml = true
  css {
    minify = true
    targets {
      new { browser = "chrome"; version = "120" }
      new { browser = "safari" }
    }
  }
}

javascript {
  ecma = "stable"
}
utf-8 · pkl · Lines: 14
PropertyMeaningDefault
web.minifyHtmlMinify HTML, including inline scripts and styles.true
web.css.minifyMinify CSS.true
web.css.targetsCSS browser targets: browser (chrome, firefox, safari, edge, opera or other) and optional version.none
web.browsersBrowser targets for all outputs; css.targets overrides it for CSS.none
javascript.ecmaDeclared ECMAScript edition: a year 2015 … 2025, "stable" or "latest". elide project info shows it; it does not change which syntax runs or how code is built (JavaScript language)."stable"

Project builds

To build a site with elide build, declare a static-site artifact. To compile Java or Kotlin for the browser, see Browser WASM.

Was this page helpful?