jsbundling-rails 0.1.2 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -1
- data/lib/install/Procfile.dev +1 -1
- data/lib/install/install.rb +7 -3
- data/lib/install/webpack/webpack.config.js +4 -2
- data/lib/jsbundling/version.rb +1 -1
- data/lib/tasks/jsbundling/build.rake +6 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2faa669bdcf9cad7f6b3c3764750ff01ed4f5c1b7deec7700157f00d1c24ffd
|
4
|
+
data.tar.gz: 70b3c1e0341354e9d3c3558c36a744791b341924e30593792ef2890d135a6744
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5902ba118b81d7abda630646497ecf2fbbd90f4051da9486d2b5ab6359b05d4055f068b35dd585bf02725e81be6784af340cddcce36994b8032bbace7504462
|
7
|
+
data.tar.gz: ef99f2630a4abea6cfb43a59475ad143ec86e55280591a0ee166798d74974703d3c45e0733b62a4f583dc995087508cdd775833e4a8342423835223e8fab5257
|
data/README.md
CHANGED
@@ -8,14 +8,18 @@ When you deploy your application to production, the `javascript:build` task atta
|
|
8
8
|
|
9
9
|
This also happens in testing where the bundler attaches to the `test:prepare` task to ensure the JavaScript has been bundled before testing commences. (Note that this currently only applies to rails `test:*` tasks (like `test:all` or `test:controllers`), not "rails test", as that doesn't load `test:prepare`).
|
10
10
|
|
11
|
+
If your testing library of choice does not define a `test:prepare` Rake task, ensure that your test suite runs `javascript:build` to bundle JavaScript before testing commences.
|
12
|
+
|
11
13
|
That's it!
|
12
14
|
|
13
15
|
You can configure your bundler options in the `build` script in `package.json` or via the installer-generated `rollup.config.js` for rollup.js or `webpack.config.json` for Webpack (esbuild does not have a default configuration format).
|
14
16
|
|
17
|
+
If you're already using [`webpacker`](https://github.com/rails/webpacker) and you're wondering if you should migrate to `jsbundling-rails`, have a look at [the high-level comparison](./docs/comparison_with_webpacker.md).
|
18
|
+
|
15
19
|
|
16
20
|
## Installation
|
17
21
|
|
18
|
-
You must already have node and yarn installed on your system. Then:
|
22
|
+
You must already have node and yarn installed on your system. You will also need npx version 7.1.0 or later. Then:
|
19
23
|
|
20
24
|
1. Add `jsbundling-rails` to your Gemfile with `gem 'jsbundling-rails'`
|
21
25
|
2. Run `./bin/bundle install`
|
data/lib/install/Procfile.dev
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
web: bin/rails server
|
1
|
+
web: bin/rails server -p 3000
|
2
2
|
js: yarn build --watch
|
data/lib/install/install.rb
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
say "Compile into app/assets/builds"
|
2
2
|
empty_directory "app/assets/builds"
|
3
3
|
keep_file "app/assets/builds"
|
4
|
-
|
4
|
+
|
5
|
+
if (sprockets_manifest_path = Rails.root.join("app/assets/config/manifest.js")).exist?
|
6
|
+
append_to_file sprockets_manifest_path, %(//= link_tree ../builds\n)
|
7
|
+
end
|
5
8
|
|
6
9
|
if Rails.root.join(".gitignore").exist?
|
7
|
-
append_to_file
|
10
|
+
append_to_file(".gitignore", %(\n/app/assets/builds/*\n!/app/assets/builds/.keep\n))
|
11
|
+
append_to_file(".gitignore", %(\n/node_modules\n))
|
8
12
|
end
|
9
13
|
|
10
14
|
if (app_layout_path = Rails.root.join("app/views/layouts/application.html.erb")).exist?
|
@@ -28,7 +32,7 @@ unless Rails.root.join("package.json").exist?
|
|
28
32
|
end
|
29
33
|
|
30
34
|
if Rails.root.join("Procfile.dev").exist?
|
31
|
-
append_to_file "Procfile.dev", "js: yarn build --watch"
|
35
|
+
append_to_file "Procfile.dev", "js: yarn build --watch\n"
|
32
36
|
else
|
33
37
|
say "Add default Procfile.dev"
|
34
38
|
copy_file "#{__dir__}/Procfile.dev", "Procfile.dev"
|
@@ -3,9 +3,11 @@ const webpack = require('webpack')
|
|
3
3
|
|
4
4
|
module.exports = {
|
5
5
|
mode: "production",
|
6
|
-
entry:
|
6
|
+
entry: {
|
7
|
+
application: "./app/javascript/application.js"
|
8
|
+
},
|
7
9
|
output: {
|
8
|
-
filename: "
|
10
|
+
filename: "[name].js",
|
9
11
|
path: path.resolve(__dirname, "app/assets/builds"),
|
10
12
|
},
|
11
13
|
plugins: [
|
data/lib/jsbundling/version.rb
CHANGED
@@ -6,4 +6,9 @@ namespace :javascript do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
Rake::Task["assets:precompile"].enhance(["javascript:build"])
|
9
|
-
|
9
|
+
|
10
|
+
if Rake::Task.task_defined?("test:prepare")
|
11
|
+
Rake::Task["test:prepare"].enhance(["javascript:build"])
|
12
|
+
elsif Rake::Task.task_defined?("db:test:prepare")
|
13
|
+
Rake::Task["db:test:prepare"].enhance(["javascript:build"])
|
14
|
+
end
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsbundling-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
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-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: railties
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|