All Projects → excid3 → esbuild-rails

excid3 / esbuild-rails

Licence: MIT license
Esbuild Rails plugin

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to esbuild-rails

RebelsManager
No description or website provided.
Stars: ✭ 61 (-40.2%)
Mutual labels:  rubyonrails, stimulusjs
stimulus-webpack-helpers
Webpack helpers for @hotwired/stimulus.
Stars: ✭ 24 (-76.47%)
Mutual labels:  stimulusjs
esbuild-vue
An esbuild plugin for loading and compiling Vue 2 single-file components.
Stars: ✭ 43 (-57.84%)
Mutual labels:  esbuild
nanobundle
Yet another build tool for libraries, powered by esbuild
Stars: ✭ 45 (-55.88%)
Mutual labels:  esbuild
awesome-programming-tutorials
📚 Collect all awesome programming tutorials
Stars: ✭ 39 (-61.76%)
Mutual labels:  rubyonrails
electron-vite-boilerplate
📚 A Electron + Vite boilerplate of the nature of learning(source-code of vite-plugin-electron) / 学习性的样板工程(vite-plugin-electron源码)
Stars: ✭ 157 (+53.92%)
Mutual labels:  esbuild
gulp-esbuild
gulp plugin for esbuild bundler
Stars: ✭ 39 (-61.76%)
Mutual labels:  esbuild
modern-rails-flash-messages
Modern Rails flash messages - Example App
Stars: ✭ 21 (-79.41%)
Mutual labels:  stimulusjs
vite-plugin-cloudflare
🔥Building Cloudflare workers is faster and easier using vite-plugin-cloudflare with node builtins like process and stream
Stars: ✭ 108 (+5.88%)
Mutual labels:  esbuild
recordstore
A Vue.js front-end paired with a Ruby on Rails API-based backend
Stars: ✭ 72 (-29.41%)
Mutual labels:  rubyonrails
esbuild-plugin-purescript
esbuild integration for PureScript
Stars: ✭ 27 (-73.53%)
Mutual labels:  esbuild
hotwire-livereload
Live reload for Hotwire Rails apps.
Stars: ✭ 231 (+126.47%)
Mutual labels:  hotwire
stimulus-transition
Enter/Leave transition for stimulusJS, inspired by Vue/Alpine syntax
Stars: ✭ 34 (-66.67%)
Mutual labels:  stimulusjs
kickstart
Ruby on Rails application templates
Stars: ✭ 61 (-40.2%)
Mutual labels:  rubyonrails
codetree
⚡️ Lightning fast online code playground, built on top of webAssembly 🔥.
Stars: ✭ 55 (-46.08%)
Mutual labels:  esbuild
stimulus-content-loader
A Stimulus controller to asynchronously load HTML from an url.
Stars: ✭ 39 (-61.76%)
Mutual labels:  stimulusjs
decent-visualizer
A visualizer for .shot files
Stars: ✭ 46 (-54.9%)
Mutual labels:  hotwire
stimulus reflex
Build reactive applications with the Rails tooling you already know and love.
Stars: ✭ 2,001 (+1861.76%)
Mutual labels:  hotwire
bootswatch-sass
bootswatch ruby gems for assets pipeline
Stars: ✭ 12 (-88.24%)
Mutual labels:  rubyonrails
sapper-typescript-esbuild-template
Sapper template with ESBuild and TypeScript
Stars: ✭ 18 (-82.35%)
Mutual labels:  esbuild

npm version

🛤 esbuild-rails

Esbuild Rails plugin for easy imports of Stimulus controllers, ActionCable channels, and other Javascript.

This package is designed to be used with jsbundling-rails.

⚙️ Installation

Install with npm or yarn

yarn add esbuild-rails
npm i esbuild-rails

Add the plugin to esbuild.config.js

const path = require('path')
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: process.argv.includes("--watch"),
  plugins: [rails()],
}).catch(() => process.exit(1))

Use npm to add it as the build script (requires npm >= 7.1)

npm set-script build "node esbuild.config.js"

or add it manually in package.json

"scripts": {
  "build": "node esbuild.config.js"
}

🧑‍💻 Usage

Import a folder using globs:

import "./src/**/*"

Import Stimulus controllers and register them:

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

import controllers from "./**/*_controller.js"
controllers.forEach((controller) => {
  application.register(controller.name, controller.module.default)
})

Import ActionCable channels:

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

jQuery with esbuild:

yarn add jquery
// app/javascript/jquery.js
import jquery from 'jquery';
window.jQuery = jquery;
window.$ = jquery;
//app/javascript/application.js
import "./jquery"

Why does this work? import in Javascript is hoisted, meaning that import is run before the other code regardless of where in the file they are. By splitting the jQuery setup into a separate import, we can guarantee that code runs first. Read more here.

jQuery UI with esbuild:

Follow the jQuery steps above.

Download jQuery UI custom build and add it to app/javascript/jquery-ui.js

import "./jquery-ui"

$(function() {
  $(document).tooltip()
  $("#dialog").dialog()
})

A custom build is required because jQueryUI does not support ESM.

🙏 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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].