esbuild-rails 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +10 -3
- data/lib/esbuild/version.rb +1 -1
- data/lib/install/install.rb +7 -9
- data/lib/install/package.json +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c374c77f9f500a218b0f34d0e87aeb94bba7e17481f71a1e149023ed6917f81
|
4
|
+
data.tar.gz: e869ad2dae5c772d14d6403d8200895dc2703ba3eec347c963481b7901cc0ad0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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/
|
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/
|
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
|
|
data/lib/esbuild/version.rb
CHANGED
data/lib/install/install.rb
CHANGED
@@ -1,18 +1,16 @@
|
|
1
|
-
say "Compile into app/assets/
|
2
|
-
empty_directory "app/assets/
|
3
|
-
keep_file "app/assets/
|
4
|
-
append_to_file "app/assets/config/manifest.js", %(//= link_tree ../
|
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/
|
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,
|
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.)
|
data/lib/install/package.json
CHANGED
@@ -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/
|
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.
|
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-
|
11
|
+
date: 2021-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|