Skip to main content

Build JavaScript files with esbuild.

Project description

plain.esbuild

Build and bundle JavaScript files using esbuild.

Overview

Plain esbuild provides a simple way to bundle JavaScript files using esbuild. Any asset file with .esbuild. in its name will be automatically bundled into a corresponding .esbuilt. file.

For example, if you have app/assets/js/app.esbuild.js, running the build command will create app/assets/js/app.esbuilt.js alongside it.

// app/assets/js/app.esbuild.js
import { someFunction } from "./utils.js";

someFunction();

After building, you can reference the bundled file in your templates:

<script src="{{ asset('js/app.esbuilt.js') }}"></script>

The bundler automatically:

  • Bundles all imports into a single file
  • Generates source maps
  • Minifies the output (in production builds)
  • Targets the browser platform

CLI commands

Build

Build all .esbuild. files in your asset directories:

plain esbuild build

This command finds all files containing .esbuild. in your asset directories and bundles them using esbuild. The output files are minified by default.

Dev

Watch for changes and rebuild automatically:

plain esbuild dev

The dev command performs an initial build (without minification) and then watches for file changes. When you modify a .esbuild. file, it will automatically rebuild. If you delete a source file, the corresponding .esbuilt. output file is also removed.

FAQs

What files should I gitignore?

Add this pattern to your .gitignore to exclude the generated bundle files:

**/assets/**/*.esbuilt.*

Do I need to install esbuild separately?

Yes, esbuild must be available via npx. Make sure you have a package.json in your project with esbuild as a dependency:

npm install --save-dev esbuild

How do I use this with plain assets build?

The esbuild commands integrate with the Plain build system through entrypoints. When you run plain assets build, it will automatically run esbuild first if you have configured it in your build pipeline.

Can I customize esbuild options?

The esbuild function accepts a minify option. For more advanced customization, you can call the function directly in your own build scripts.

Installation

Install the plain.esbuild package from PyPI:

uv add plain.esbuild

Make sure you have esbuild available in your project:

npm install --save-dev esbuild

Create a JavaScript file with .esbuild. in the name:

// app/assets/js/app.esbuild.js
console.log("Hello from esbuild!");

Run the build command:

plain esbuild build

Add the generated files to your .gitignore:

**/assets/**/*.esbuilt.*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

plain_esbuild-0.9.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

plain_esbuild-0.9.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file plain_esbuild-0.9.0.tar.gz.

File metadata

  • Download URL: plain_esbuild-0.9.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for plain_esbuild-0.9.0.tar.gz
Algorithm Hash digest
SHA256 dbf1362bc9d288bd8eddb336677ad5be51505015e1687102a1a31f40b46122f7
MD5 6cf2c2137339fb337c2da38f612e61a6
BLAKE2b-256 0bed4383f21bf70be085e1afda80fca8f48d9b1a463471b1b2480cce681b2f4d

See more details on using hashes here.

File details

Details for the file plain_esbuild-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: plain_esbuild-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for plain_esbuild-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6a8bcfaaadde16e60fb81a67b0b041e6edae6a9d23d6fcb2a6bf4b9891e5453c
MD5 cb57d07f9b6523842e9842fa5dfea05b
BLAKE2b-256 c0881d92b49041170dff3e5b507a689419cf12024927650885877a2682c8b0fc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page