jsbundling-rails 0.1.4 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- 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 +9 -2
- 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: e53bb1aef74de39d8fdbe9a5f234d0a34d9cc26cc84b708711c0eaadb77f4dcd
|
4
|
+
data.tar.gz: c5b34643c871c1d74f6c763fd6ebea88e305349b70500cc54e1f973cdbb6821f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 348217cf1a66e4b84f293102308fae17c48ef09ece24fe2cfbe408bdee570de7766704a82737a892a89d38e034282823ce2ac93ae18207f75ae76555c31c1499
|
7
|
+
data.tar.gz: 94ea08798d3ab189f4bdd89037a4a0fe547a1b27438b1a6127023f8fc3b87c44ae629e7b65871a79f55bc0dec15211d2b01b212acefcd96e0bad998cbb10925a
|
data/README.md
CHANGED
@@ -8,10 +8,14 @@ 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
|
|
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(".gitignore", %(/app/assets/builds
|
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
@@ -1,9 +1,16 @@
|
|
1
1
|
namespace :javascript do
|
2
2
|
desc "Build your JavaScript bundle"
|
3
3
|
task :build do
|
4
|
-
system "yarn install && yarn build"
|
4
|
+
unless system "yarn install && yarn build"
|
5
|
+
raise "jsbundling-rails: Command build failed, ensure yarn is installed and `yarn build` runs without errors"
|
6
|
+
end
|
5
7
|
end
|
6
8
|
end
|
7
9
|
|
8
10
|
Rake::Task["assets:precompile"].enhance(["javascript:build"])
|
9
|
-
|
11
|
+
|
12
|
+
if Rake::Task.task_defined?("test:prepare")
|
13
|
+
Rake::Task["test:prepare"].enhance(["javascript:build"])
|
14
|
+
elsif Rake::Task.task_defined?("db:test:prepare")
|
15
|
+
Rake::Task["db:test:prepare"].enhance(["javascript:build"])
|
16
|
+
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.8
|
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-28 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
|
- - ">="
|