0.0
The project is in a healthy, maintained state
This plugin uses esbuild to process the targeted JavaScript static files in a Jekyll site whenever the site is built. By default, it targets all static files with .js extension, but it can be configured to target only the files specified in a list, which also allows including files of other content types supported by esbuild, such as TypeScript or JSX (still untested with this plugin, however). There are also other options to toggle bundling, minification, and source maps.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

>= 2.0
>= 12.0

Runtime

>= 3.0
>= 0
 Project Readme

jekyll-esbuild

This plugin uses esbuild to process the targeted JavaScript static files in a Jekyll site whenever the site is built.

Installation

Add jekyll-esbuild to your Gemfile in the :jekyll_plugins section to install the gem and enable it in Jekyll automatically (since Jekyll v4):

group :jekyll_plugins do
  gem 'jekyll-esbuild'
end

For earlier versions of Jekyll, you'll also have to add jekyll-esbuild to the plugins section of your _config.yml:

plugins:
  - jekyll-esbuild

In any case, don't forget to install esbuild using npm at the root of your Jekyll source directory:

npm install esbuild

Configuration

To configure this plugin, add a section called esbuild to your _config.yml and set one or more of the following options:

  • script: String path. Default: node_modules/.bin/esbuild. Path to esbuild's executable binary in your system. If you installed esbuild locally in your Jekyll source directory as recommended above, the default value should work.
  • bundle: Boolean (true / false). Default: true. Enables or disables the --bundle option that tells esbuild to bundle the files, that is, to inline any imported dependencies into the file itself.
  • minify: String with three possible values (always / never / environment). Default: environment. Specifies whether or not to enable the --minify option that tells esbuild to minify the files. If set to environment, it enables the option only if the value of NODE_ENV environment variable is set to production.
  • sourcemap: String with three possible values (always / never / environment). Default: environment. Specifies whether or not to enable the --sourcemap option that tells esbuild to generate source maps for the files and link them. If set to environment, it enables the option only if the value of NODE_ENV environment variable is not set to production.
  • files: List of string paths. Default: not set. Specifies the relative paths of each of the JavaScript static files that you want to process with esbuild. Actually, esbuild also supports other content types besides vanilla JavaScript, so you can use this option to specify TypeScript files or JSX files, for example, but that hasn't been tested yet with this plugin. The paths must be relative to the root of your Jekyll source directory, and they must have a leading slash. If not set, the plugin will process every single static file with .js extension in your site.

Example:

esbuild:
  script: node_modules/.bin/esbuild
  bundle: true
  minify: environment
  sourcemap: never
  files:
    - /assets/js/main.js
    - /assets/js/another.js

If you like the default settings, you can simply use the plugin without adding any settings to your _config.yml, or you can set only the settings that you want to change and skip those where you're satisfied with the default value.

Usage

Build your site with jekyll build or jekyll serve as usual. This plugin will automatically process the targeted files using esbuild with the configured options, logging to console the paths of the processed files or any error that occurs.

Example console output:

Configuration file: /srv/jekyll/_config.yml
            Source: /srv/jekyll
       Destination: /srv/jekyll/_site
 Incremental build: disabled. Enable with --incremental
      Generating... 
     JekyllEsbuild: Processed /srv/jekyll/_site/assets/js/main.js
     JekyllEsbuild: Processed /srv/jekyll/_site/assets/js/another.js
                    done in 1.234 seconds.
 Auto-regeneration: enabled for '/srv/jekyll'
    Server address: http://0.0.0.0:4000/
  Server running... press ctrl-c to stop.