esbuild-rails 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6981c18075254b8cf323625401fd3ac8e4823cd7c751de38b62cad747011e5a
4
- data.tar.gz: c157fb4d1ab9390d1b687ec101ec54f2a986875912c7e57fbc1f4d7efd321916
3
+ metadata.gz: 8c374c77f9f500a218b0f34d0e87aeb94bba7e17481f71a1e149023ed6917f81
4
+ data.tar.gz: e869ad2dae5c772d14d6403d8200895dc2703ba3eec347c963481b7901cc0ad0
5
5
  SHA512:
6
- metadata.gz: b92bdd273cb9fbdbe188cef5ee63ed095ca051af2445caad93955e1d396c995c6b8a47a72807eda2ed49e149fc12bbf6e22e12d63b98cbc1954b005c5006b53f
7
- data.tar.gz: 041e8bfa9e2a8008dbb39f2907ee4550fdd381ec6fd0ee2ceac2ae826c9ee1a675daecde7a0b384a6972c883230f89e126ed7f8140cf0a4612c9b90e6aae19a1
6
+ metadata.gz: 5752a20e9cd306fbdf601f44df91998178dd9b32e03a32ee3308e0e5d7640c769ad97fab72033c13912d4dfec05ec592815f4f6229765c3b45bcb7d7abe264d5
7
+ data.tar.gz: 85f4e550cf3d05790fbf1c0322deee0a967e9d7fedbaff5af1d90e54f0d5b3c785ea79712688662dcea3773dde469e456d9906a566bb822684c1dd7ffa5fdb5b
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # esbuild for Rails
2
2
 
3
- Use [esbuild](https://esbuild.github.io) to bundle your JavaScript and deliver it via the asset pipeline in Rails. This gem provides an installer to get you going with esbuild in a new Rails application, and a convention to use `app/assets/esbuilds` to hold your bundled output as artifacts that are not checked into source control (the installer adds this directory to `.gitignore` by default).
3
+ Use [esbuild](https://esbuild.github.io) to bundle your JavaScript, then deliver it via the asset pipeline in Rails. This gem provides an installer to get you going with esbuild in a new Rails application, and a convention to use `app/assets/builds` to hold your bundled output as artifacts that are not checked into source control (the installer adds this directory to `.gitignore` by default).
4
4
 
5
- You develop using this approach by running esbuild in watch mode in a terminal with `yarn build --watch` (and your Rails server in another, if you're not using something like [puma-dev](https://github.com/puma/puma-dev). Whenever esbuild detects changes to any of the JavaScript files in your project, it'll bundle `app/javascript/application.js` into `app/assets/esbuilds/javascript.js`. You can refer to the build output in your layout using the standard asset pipeline approach with `<%= javascript_include_tag "application" %>`.
5
+ You develop using this approach by running esbuild in watch mode in a terminal with `yarn build --watch` (and your Rails server in another, if you're not using something like [puma-dev](https://github.com/puma/puma-dev)). Whenever esbuild detects changes to any of the JavaScript files in your project, it'll bundle `app/javascript/application.js` into `app/assets/builds/javascript.js`. You can refer to the build output in your layout using the standard asset pipeline approach with `<%= javascript_include_tag "application" %>`.
6
6
 
7
- When you deploy your application to production, esbuild attaches to the `assets:precompile` task to ensure that all your package dependencies from `package.json` have been installed via npm, and then runs `yarn build` to process `app/javascript/application.js` into `app/assets/esbuilds/javascript.js`. The latter file is then picked up by the asset pipeline, digested, and copied into public/assets, as any other asset pipeline file.
7
+ When you deploy your application to production, esbuild attaches to the `assets:precompile` task to ensure that all your package dependencies from `package.json` have been installed via npm, and then runs `yarn build` to process `app/javascript/application.js` into `app/assets/builds/javascript.js`. The latter file is then picked up by the asset pipeline, digested, and copied into public/assets, as any other asset pipeline file.
8
8
 
9
9
  That's it!
10
10
 
@@ -19,6 +19,13 @@ You must already have node and yarn installed on your system. Then:
19
19
  2. Run `./bin/bundle install`
20
20
  3. Run `./bin/rails esbuild:install`
21
21
 
22
+ Or, in Rails 7+, you can preconfigure your new application to use esbuild with `rails new myapp -j esbuild`.
23
+
24
+
25
+ ## The sister gem to rollupjs-rails
26
+
27
+ This gem is almost identical in setup and purpose to [`rollupjs-rails`](https://github.com/rails/rollupjs-rails), which follows the same conventions, but uses [rollup.js](https://rollupjs.org) instead.
28
+
22
29
 
23
30
  ## License
24
31
 
@@ -1,3 +1,3 @@
1
1
  module Esbuild
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -1,18 +1,16 @@
1
- say "Compile into app/assets/esbuilds"
2
- empty_directory "app/assets/esbuilds"
3
- keep_file "app/assets/esbuilds"
4
- append_to_file "app/assets/config/manifest.js", %(//= link_tree ../esbuilds .js\n)
1
+ say "Compile into app/assets/builds"
2
+ empty_directory "app/assets/builds"
3
+ keep_file "app/assets/builds"
4
+ append_to_file "app/assets/config/manifest.js", %(//= link_tree ../builds .js\n)
5
5
 
6
6
  if Rails.root.join(".gitignore").exist?
7
- append_to_file ".gitignore", %(\n/app/assets/esbuilds\n)
7
+ append_to_file ".gitignore", %(\n/app/assets/builds\n)
8
8
  end
9
9
 
10
10
  if (app_layout_path = Rails.root.join("app/views/layouts/application.html.erb")).exist?
11
11
  say "Add esbuild include tag in application layout"
12
- insert_into_file app_layout_path.to_s, before: /\s*<\/head>/ do <<-HTML
13
- \n <%= javascript_include_tag "application", "data-track-turbo": "true", defer: true %>
14
- HTML
15
- end
12
+ insert_into_file app_layout_path.to_s,
13
+ %(\n <%= javascript_include_tag "application", "data-track-turbo": "true", defer: true %>), before: /\s*<\/head>/
16
14
  else
17
15
  say "Default application.html.erb is missing!", :red
18
16
  say %( Add <%= javascript_include_tag "application", "data-track-turbo": "true", defer: true %> within the <head> tag in your custom layout.)
@@ -2,6 +2,6 @@
2
2
  "name": "myapp",
3
3
  "private": "true",
4
4
  "scripts": {
5
- "build": "esbuild app/javascript/application.js --outfile=app/assets/esbuilds/application.js --bundle"
5
+ "build": "esbuild app/javascript/application.js --outfile=app/assets/builds/application.js --bundle"
6
6
  }
7
7
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: esbuild-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-03 00:00:00.000000000 Z
11
+ date: 2021-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails