Rails plugin for Esbuild

Overview

🛤 esbuild-rails

Rails plugin for Esbuild to help loading Stimulus controllers, ActionCable channels, and other Javascript.

⚙️ Installation

Install with npm or yarn

yarn add esbuild-rails
npm i esbuild-rails

Add the plugin to esbuild.config.js

const rails = require('esbuild-rails');

require("esbuild").build({
  entryPoints: ["application.js"],
  bundle: true,
  outdir: path.join(process.cwd(), "app/assets/builds"),
  absWorkingDir: path.join(process.cwd(), "app/javascript"),
  watch: watch,
  plugins: [rails()],
}).catch(() => process.exit(1));

🧑‍💻 Usage

Import a folder using globs:

import "./src/**/*"

Import Stimulus controllers and register them:

import { Application } from "@hotwired/stimulus"
const application = Application.start()

import * as controllers from "./**/*_controller.js"
for (let i=0; i < controllers.filenames.length; i++) {
  const name = controllers.filenames[i]
    .replace("./", "")
    .replace("_controller.js", "")
    .replace(/\//g, "--")
    .replace(/_/g, '-')
  application.register(name, controllers.default[i].default)
}

Import ActionCable channels:

import "./channels/**/*_channel.js"

🙏 Contributing

If you have an issue you'd like to submit, please do so using the issue tracker in GitHub. In order for us to help you in the best way possible, please be as detailed as you can.

📝 License

The gem is available as open source under the terms of the MIT License.

You might also like...

🤠 An opinionated AJAX client for Ruby on Rails APIs

Rails Ranger Exploring the routes and paths of Ruby on Rails APIs Github Repository | Documentation Rails Ranger is a thin layer on top of Axios, whic

Nov 22, 2022

Use ESM with importmap to manage modern JavaScript in Rails without transpiling or bundling.

Importmap for Rails Use ESM with importmap to manage modern JavaScript in Rails without transpiling or bundling. Installation ... Usage ... License Im

Jan 7, 2023

Base Rails app that includes login, social login, homepage, and basic model for serving as a scaffold app.

Base Rails app that includes login, social login, homepage, and basic model for serving as a scaffold app.

Rails7Base I created the Rails7Base as a scaffold application. Countless times, I had to create apps that must have the following features: Login syst

Jul 2, 2022

Steam Game - Nimby Rails

Nimby-Rails-Mod.txt-File-Tools Steam Game - Nimby Rails zh: 这是Steam中的一个铁道游戏《Nimby Rails》的Mod配置文件编辑器。 这个配置文件编辑器用的是纯JS语法 用了HTML+CSS+JS+JQuery+一点点的Vue 本质

Jun 14, 2022

esbuild plugin to generate mix-manifest.json file compatible with Laravel Mix.

esbuild-mix-manifest-plugin An esbuild plugin to generate a mix-manifest.json compatible with Laravel Mix. Installation You can install the plugin via

Dec 25, 2022

An esbuild plugin to inject your application's version number or today's date into your files

esbuild-plugin-version-injector An esbuild plugin to inject your application's version number or today's date into your files This plugin was inspired

Dec 6, 2022

An esbuild plugin for simplifying global API calls.

esbuild-plugin-global-api This plugin is still experimental, not recommended for production. It may break your code in some cases. An esbuild plugin f

Nov 15, 2022

Example project using Miniflare, esbuild and AVA

Miniflare Example Project This is an example Cloudflare Workers project that uses Miniflare for local development, esbuild for bundling, and AVA for t

Dec 3, 2022

Lightweight and versatile build tool based on the esbuild compiler

Lightweight and versatile build tool based on the esbuild compiler

Estrella is a lightweight and versatile build tool based on the fantastic esbuild TypeScript and JavaScript compiler. Rebuild automatically when sourc

Jan 2, 2023

⚡️ Fast, lightweight and powerful development server for esbuild ⚡️

esbuild-server ⚡️ Fast, lightweight and powerful development server for esbuild ⚡️ Zero dependencies besides esbuild API proxy support Live reload SPA

Sep 14, 2022

This is a library that makes it possible to change the configuration values of the Remix compiler (esbuild).

💽 remix-esbuild-override ⚠️ While I believe you will most likely get a lot of benefit from using this library, it can sometimes destroy your product.

Dec 22, 2022

Build your Cloudflare Workers with esbuild.

build-worker Bundle your Cloudflare Worker with esbuild instead of webpack. (It's ridiculously faster!) Wrangler v1 uses webpack. Wrangler v2 is using

Oct 24, 2022

🚀 Using top-level await in AWS Lambda with TypeScript, esbuild and Serverless Framework

🚀 Using top-level await in AWS Lambda with TypeScript, esbuild and Serverless Framework

🚀 Top-level await in AWS Lamba with TypeScript Articles https://dev.to/oieduardorabelo/top-level-await-in-aws-lamba-with-typescript-1bf0 https://medi

Nov 23, 2022

This is the leaflet plugin for GeoServer. Using this plugin user can have access to wms and wfs request easily.

This is the leaflet plugin for GeoServer. Using this plugin user can have access to wms and wfs request easily.

Documentation leaflet-geoserver-request This is the plugin for Geoserver various kind of requests. Using this plugin, we can make WMS, WFS, getLegendG

Dec 15, 2022

Babel-plugin-amd-checker - Module format checking plugin for Babel usable in both Node.js the web browser environments.

babel-plugin-amd-checker A Babel plugin to check the format of your modules when compiling your code using Babel. This plugin allows you to abort the

Jan 6, 2022

Vite-plugin-web-extension - A vite plugin for generating cross browser platform, ES module based web extensions.

vite-plugin-web-extension A vite plugin for generating cross browser platform, ES module based web extensions. Features Manifest V2 & V3 Support Compl

Dec 31, 2022

A variety of jQuery plugin patterns for jump starting your plugin development

jQuery Plugin Patterns So, you've tried out jQuery Boilerplate or written a few of your own plugins before. They work to a degree and are readable, bu

Dec 31, 2022
Comments
  • Production/Heroku issues?

    Production/Heroku issues?

    Is there any additional configuration needed to get this working in production on Heroku? Everything works fine locally but when deployed there are no CSS or JavaScript assets.


    P.S. Thanks so much for this – being able to glob import Stimulus controllers is 🔥

    opened by joemasilotti 5
  • File to paste the

    File to paste the "import stimulus controllers and register them" into

    I'm just checking the usage instructions for esbuild-rails. It doesn't say which file you are supposed to paste the code into. The import hotwired/stimulus code looks like the start of javascript/controllers/application.js. But in the screencast, you pasted just the controller code into the autogenerated file javascript/controllers/index.js.

    Import Stimulus controllers and register them:

    // app/javascript/ ???
    import { Application } from "@hotwired/stimulus"
    const application = Application.start()
    
    import controllers from "./**/*_controller.js"
    controllers.forEach((controller) => {
      application.register(controller.name, controller.module.default)
    })
    
    opened by notapatch 2
  • Configurable file extension to support other files like .jsx

    Configurable file extension to support other files like .jsx

    Using an option, we can have a default regex that can be overridden for matching filenames.

    We'll replace

          ).sort().filter(path => path.endsWith('.js'));
    

    with

    .filter(path => /.jsx?$/.test(path))
    
    enhancement 
    opened by excid3 1
  • Can it write out which file(s) were built?

    Can it write out which file(s) were built?

    I don't know if this is related to esbuild or esbuild-rails but, when I'm running my bin/dev script, the result of my javascript compilation isn't being output. Each time the sass plugin compiles a file it shows up in my Foreman output.

    I'd love it if the javascript compilation process did that too. My config file is the same as in the README, except for the entry points.

    Is this something that can be done?

    (e)

    opened by silent-e 0
Releases(v1.0.3)
  • v1.0.3(Oct 3, 2021)

    • Improve default export and import all files (not just .js) 88ddd5f
    • Update readme a8e6955

    https://github.com/excid3/esbuild-rails/compare/v1.0.2...v1.0.3

    Source code(tar.gz)
    Source code(zip)
  • v1.0.2(Oct 2, 2021)

  • v1.0.1(Sep 25, 2021)

    • Add missing path require 90b5195
    • Emojis 779a40e
    • Update readme with examples d3979eb

    https://github.com/excid3/esbuild-rails/compare/v1.0.0...v1.0.1

    Source code(tar.gz)
    Source code(zip)
  • v1.0.0(Sep 25, 2021)

    • Add ignore 762934a
    • Reset version 49da3be
    • Export plugin ae9cc2d
    • Add readme 3409ff7

    https://github.com/excid3/esbuild-rails/compare/520b8225fbe489d5d342fff67bba357dd4d984ff...v1.0.0

    Source code(tar.gz)
    Source code(zip)
Owner
Chris Oliver
Chris Oliver
UX plugin for Oxygen Builder

=== Recoda Workspace for Oxygen === Contributors: Renato Corluka Donate link: https://paypal.me/__insert_some_pp_me Tags: oxygen, oxygen builder, util

null 40 Dec 3, 2022
Obsidian plugin with options to customize the behavior of CodeMirror

Obsidian CodeMirror Options This plugin adds configurable options to customize the behavior of CodeMirror. Installation Manual Installation To manuall

null 145 Dec 31, 2022
Template to create a new @Grafana application plugin.

Template to create a new Grafana application plugin Introduction The ABC Application is a template to create a new application plugin for Grafana. Req

Volkov Labs 5 Aug 17, 2022
Example VS Code plugin that uses embedded Omega Edit bindings to generate content

Ωedit Edit for VS Code Example VS Code plugin that uses embedded Omega Edit bindings to generate content. Build Requirements Bindings compiled against

Concurrent Technologies Corporation (CTC) 2 Nov 17, 2022
A Neos CMS plugin which provides a button editor

I13e.ButtonEditor Button editor for Neos CMS This package provides a new inspector editor displaying it's options as buttons. Buttons operates like ch

Ideenstadtwerke 9 Jun 10, 2022
WYSIWYG editor developed as jQuery plugin

RichText WYSIWYG editor developed as jQuery plugin. Requirements jQuery (v.3+, v.3.2+ recommended) FontAwesome (v.4.7.0 / v.5+) src/jquery.richtext.mi

Bob 95 Dec 30, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023