shakapacker 6.3.0 → 6.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -5
- data/Gemfile +2 -1
- data/Gemfile.lock +84 -74
- data/README.md +148 -70
- data/docs/sprockets.md +10 -0
- data/lib/install/config/webpacker.yml +8 -0
- data/lib/tasks/webpacker/compile.rake +2 -10
- data/lib/tasks/webpacker.rake +0 -1
- data/lib/webpacker/configuration.rb +4 -1
- data/lib/webpacker/version.rb +1 -1
- data/package/environments/__tests__/base.js +30 -3
- data/package/environments/base.js +8 -1
- data/package.json +2 -2
- data/test/rake_tasks_test.rb +0 -34
- data/test/test_app/app/packs/entrypoints/generated/something.js +2 -0
- data/test/test_app/config/webpacker.yml +1 -0
- data/test/test_app/config/webpacker_nested_entries.yml +83 -0
- metadata +8 -5
- data/lib/tasks/webpacker/yarn_install.rake +0 -18
- data/lib/tasks/yarn.rake +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41d452e91baefc4e4235ab82c30a8a5fb6cfa98854016124f8214b8b2f475986
|
4
|
+
data.tar.gz: '08fb5cd0691f29a12862b827d1fc247565300256e21ba2dead9a2e1d128cc2a2'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c39f8cd91ea7a0a786341ddbc115d91c30dee7826914c0fcb85ab1f9e52b0719706b4d7343922184f8beefaa20de7fa7d7fa760a36bb06e2f73c38a6d965d792
|
7
|
+
data.tar.gz: c70a8973e7f69d60ceab67055b6c597b8ace1ba72137b2dc4a3902f9e3fae71f393aaa4dc82f5253f57c3e559b56b0d2a12f4f3234f0249c234b8f3106162b3c
|
data/CHANGELOG.md
CHANGED
@@ -6,7 +6,19 @@
|
|
6
6
|
## [Unreleased]
|
7
7
|
Changes since last non-beta release.
|
8
8
|
|
9
|
-
|
9
|
+
_Please add entries here for your pull requests that are not yet released._
|
10
|
+
|
11
|
+
## [v6.4.0] - June 2, 2022
|
12
|
+
### Fixed
|
13
|
+
- Fixed [Issue 123: Rails 7.0.3 - Webpacker configuration file not found when running rails webpacker:install (shakapacker v6.3)](https://github.com/shakacode/shakapacker/issues/123) in [PR 136: Don't enhance precompile if no config #136](https://github.com/shakacode/shakapacker/pull/136) by [justin808](https://github.com/justin808).
|
14
|
+
|
15
|
+
### Added
|
16
|
+
- Configuration boolean option `nested_entries` to use nested entries. This was the default prior to v6.0. Because entries maybe generated, it's useful to allow a `generated` subdirectory. [PR 121](https://github.com/shakacode/shakapacker/pull/121) by [justin808](https://github.com/justin808).
|
17
|
+
|
18
|
+
### Improved
|
19
|
+
- Allow v10 of `compression-webpack-plugin` as a peer dependency. [PR 117](https://github.com/shakacode/shakapacker/pull/117) by [aried3r](https://github.com/aried3r).
|
20
|
+
|
21
|
+
- [Remove assets:precompile task enhancement #131](https://github.com/shakacode/shakapacker/pull/131) by [James Herdman](https://github.com/jherdman): Removed the `yarn:install` Rake task, and no longer enhance `assets:precompile` with said task. These tasks were used to ensure required NPM packages were installed before asset precompilation. Going forward you will need to ensure these packages are already installed yourself. Should you wish to restore this behaviour you'll need to [reimplement the task](https://github.com/shakacode/shakapacker/blob/bee661422f2c902aa8ac9cf8fa1f7ccb8142c914/lib/tasks/yarn.rake) in your own application.
|
10
22
|
|
11
23
|
## [v6.3.0] - May 19, 2022
|
12
24
|
|
@@ -34,7 +46,7 @@ Note: [Rubygem is 6.3.0.pre.rc.1](https://rubygems.org/gems/shakapacker/versions
|
|
34
46
|
### Improved
|
35
47
|
- Use last modified timestamps rather than file digest to determine compiler freshness. [PR 97](https://github.com/shakacode/shakapacker/pull/97) by [tomdracz](https://github.com/tomdracz).
|
36
48
|
|
37
|
-
Rather than calculating SHA digest of all the files in the paths watched by the compiler, we are now comparing the modified time of the `manifest.json` file
|
49
|
+
Rather than calculating SHA digest of all the files in the paths watched by the compiler, we are now comparing the modified time of the `manifest.json` file versus the latest modified timestamp of files and directories in watched paths. Unlike calculating digest, which only looked at the files, the new calculation also considers directory timestamps, including the parent ones (i.e. `config.source_path` folder timestamp will be checked together will timestamps of all files and directories inside of it).
|
38
50
|
|
39
51
|
This change should result in improved compiler checks performance but might be breaking for certain setups and edge cases. If you encounter any issues, please report them at https://github.com/shakacode/shakapacker/issues.
|
40
52
|
|
@@ -125,9 +137,9 @@ Note: [Rubygem is 6.3.0.pre.rc.1](https://rubygems.org/gems/shakapacker/versions
|
|
125
137
|
## v5.4.3 and prior changes from rails/webpacker
|
126
138
|
See [CHANGELOG.md in rails/webpacker (up to v5.4.3)](https://github.com/rails/webpacker/blob/master/CHANGELOG.md)
|
127
139
|
|
128
|
-
[Unreleased]: https://github.com/shakacode/shakapacker/compare/v6.
|
129
|
-
[v6.
|
130
|
-
[v6.3.0
|
140
|
+
[Unreleased]: https://github.com/shakacode/shakapacker/compare/v6.4.0...master
|
141
|
+
[v6.4.0]: https://github.com/shakacode/shakapacker/compare/v6.3.0...v6.4.0
|
142
|
+
[v6.3.0]: https://github.com/shakacode/shakapacker/compare/v6.2.1...v6.3.0
|
131
143
|
[v6.2.1]: https://github.com/shakacode/shakapacker/compare/v6.2.0...v6.2.1
|
132
144
|
[v6.2.0]: https://github.com/shakacode/shakapacker/compare/v6.1.1...v6.2.0
|
133
145
|
[v6.1.1]: https://github.com/shakacode/shakapacker/compare/v6.1.0...v6.1.1
|
data/Gemfile
CHANGED
@@ -2,10 +2,11 @@ source "https://rubygems.org"
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
gem "rails"
|
5
|
+
gem "rails", ">= 6.1.6"
|
6
6
|
gem "rake", ">= 11.1"
|
7
7
|
gem "rack-proxy", require: false
|
8
8
|
gem "semantic_range", require: false
|
9
|
+
gem "nokogiri", "~> 1.13", ">= 1.13.6"
|
9
10
|
|
10
11
|
group :test do
|
11
12
|
gem "minitest", "~> 5.0"
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
shakapacker (6.3.0
|
4
|
+
shakapacker (6.3.0)
|
5
5
|
activesupport (>= 5.2)
|
6
6
|
rack-proxy (>= 0.6.1)
|
7
7
|
railties (>= 5.2)
|
@@ -10,60 +10,60 @@ PATH
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
actioncable (6.1.
|
14
|
-
actionpack (= 6.1.
|
15
|
-
activesupport (= 6.1.
|
13
|
+
actioncable (6.1.6)
|
14
|
+
actionpack (= 6.1.6)
|
15
|
+
activesupport (= 6.1.6)
|
16
16
|
nio4r (~> 2.0)
|
17
17
|
websocket-driver (>= 0.6.1)
|
18
|
-
actionmailbox (6.1.
|
19
|
-
actionpack (= 6.1.
|
20
|
-
activejob (= 6.1.
|
21
|
-
activerecord (= 6.1.
|
22
|
-
activestorage (= 6.1.
|
23
|
-
activesupport (= 6.1.
|
18
|
+
actionmailbox (6.1.6)
|
19
|
+
actionpack (= 6.1.6)
|
20
|
+
activejob (= 6.1.6)
|
21
|
+
activerecord (= 6.1.6)
|
22
|
+
activestorage (= 6.1.6)
|
23
|
+
activesupport (= 6.1.6)
|
24
24
|
mail (>= 2.7.1)
|
25
|
-
actionmailer (6.1.
|
26
|
-
actionpack (= 6.1.
|
27
|
-
actionview (= 6.1.
|
28
|
-
activejob (= 6.1.
|
29
|
-
activesupport (= 6.1.
|
25
|
+
actionmailer (6.1.6)
|
26
|
+
actionpack (= 6.1.6)
|
27
|
+
actionview (= 6.1.6)
|
28
|
+
activejob (= 6.1.6)
|
29
|
+
activesupport (= 6.1.6)
|
30
30
|
mail (~> 2.5, >= 2.5.4)
|
31
31
|
rails-dom-testing (~> 2.0)
|
32
|
-
actionpack (6.1.
|
33
|
-
actionview (= 6.1.
|
34
|
-
activesupport (= 6.1.
|
32
|
+
actionpack (6.1.6)
|
33
|
+
actionview (= 6.1.6)
|
34
|
+
activesupport (= 6.1.6)
|
35
35
|
rack (~> 2.0, >= 2.0.9)
|
36
36
|
rack-test (>= 0.6.3)
|
37
37
|
rails-dom-testing (~> 2.0)
|
38
38
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
39
|
-
actiontext (6.1.
|
40
|
-
actionpack (= 6.1.
|
41
|
-
activerecord (= 6.1.
|
42
|
-
activestorage (= 6.1.
|
43
|
-
activesupport (= 6.1.
|
39
|
+
actiontext (6.1.6)
|
40
|
+
actionpack (= 6.1.6)
|
41
|
+
activerecord (= 6.1.6)
|
42
|
+
activestorage (= 6.1.6)
|
43
|
+
activesupport (= 6.1.6)
|
44
44
|
nokogiri (>= 1.8.5)
|
45
|
-
actionview (6.1.
|
46
|
-
activesupport (= 6.1.
|
45
|
+
actionview (6.1.6)
|
46
|
+
activesupport (= 6.1.6)
|
47
47
|
builder (~> 3.1)
|
48
48
|
erubi (~> 1.4)
|
49
49
|
rails-dom-testing (~> 2.0)
|
50
50
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
51
|
-
activejob (6.1.
|
52
|
-
activesupport (= 6.1.
|
51
|
+
activejob (6.1.6)
|
52
|
+
activesupport (= 6.1.6)
|
53
53
|
globalid (>= 0.3.6)
|
54
|
-
activemodel (6.1.
|
55
|
-
activesupport (= 6.1.
|
56
|
-
activerecord (6.1.
|
57
|
-
activemodel (= 6.1.
|
58
|
-
activesupport (= 6.1.
|
59
|
-
activestorage (6.1.
|
60
|
-
actionpack (= 6.1.
|
61
|
-
activejob (= 6.1.
|
62
|
-
activerecord (= 6.1.
|
63
|
-
activesupport (= 6.1.
|
64
|
-
marcel (~> 1.0
|
54
|
+
activemodel (6.1.6)
|
55
|
+
activesupport (= 6.1.6)
|
56
|
+
activerecord (6.1.6)
|
57
|
+
activemodel (= 6.1.6)
|
58
|
+
activesupport (= 6.1.6)
|
59
|
+
activestorage (6.1.6)
|
60
|
+
actionpack (= 6.1.6)
|
61
|
+
activejob (= 6.1.6)
|
62
|
+
activerecord (= 6.1.6)
|
63
|
+
activesupport (= 6.1.6)
|
64
|
+
marcel (~> 1.0)
|
65
65
|
mini_mime (>= 1.1.0)
|
66
|
-
activesupport (6.1.
|
66
|
+
activesupport (6.1.6)
|
67
67
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
68
68
|
i18n (>= 1.6, < 2)
|
69
69
|
minitest (>= 5.1)
|
@@ -72,61 +72,67 @@ GEM
|
|
72
72
|
ast (2.4.2)
|
73
73
|
builder (3.2.4)
|
74
74
|
byebug (11.1.3)
|
75
|
-
concurrent-ruby (1.1.
|
75
|
+
concurrent-ruby (1.1.10)
|
76
76
|
crass (1.0.6)
|
77
77
|
erubi (1.10.0)
|
78
|
-
globalid (0.
|
78
|
+
globalid (1.0.0)
|
79
79
|
activesupport (>= 5.0)
|
80
|
-
i18n (1.
|
80
|
+
i18n (1.10.0)
|
81
81
|
concurrent-ruby (~> 1.0)
|
82
|
-
loofah (2.
|
82
|
+
loofah (2.18.0)
|
83
83
|
crass (~> 1.0.2)
|
84
84
|
nokogiri (>= 1.5.9)
|
85
85
|
mail (2.7.1)
|
86
86
|
mini_mime (>= 0.1.1)
|
87
87
|
marcel (1.0.2)
|
88
88
|
method_source (1.0.0)
|
89
|
-
mini_mime (1.1.
|
90
|
-
mini_portile2 (2.
|
91
|
-
minitest (5.
|
89
|
+
mini_mime (1.1.2)
|
90
|
+
mini_portile2 (2.8.0)
|
91
|
+
minitest (5.15.0)
|
92
92
|
nio4r (2.5.8)
|
93
|
-
nokogiri (1.
|
94
|
-
mini_portile2 (~> 2.
|
93
|
+
nokogiri (1.13.6)
|
94
|
+
mini_portile2 (~> 2.8.0)
|
95
|
+
racc (~> 1.4)
|
96
|
+
nokogiri (1.13.6-arm64-darwin)
|
97
|
+
racc (~> 1.4)
|
98
|
+
nokogiri (1.13.6-x86_64-darwin)
|
99
|
+
racc (~> 1.4)
|
100
|
+
nokogiri (1.13.6-x86_64-linux)
|
95
101
|
racc (~> 1.4)
|
96
102
|
parallel (1.21.0)
|
97
103
|
parser (3.0.2.0)
|
98
104
|
ast (~> 2.4.1)
|
99
|
-
racc (1.
|
100
|
-
rack (2.2.3)
|
105
|
+
racc (1.6.0)
|
106
|
+
rack (2.2.3.1)
|
101
107
|
rack-proxy (0.7.0)
|
102
108
|
rack
|
103
109
|
rack-test (1.1.0)
|
104
110
|
rack (>= 1.0, < 3)
|
105
|
-
rails (6.1.
|
106
|
-
actioncable (= 6.1.
|
107
|
-
actionmailbox (= 6.1.
|
108
|
-
actionmailer (= 6.1.
|
109
|
-
actionpack (= 6.1.
|
110
|
-
actiontext (= 6.1.
|
111
|
-
actionview (= 6.1.
|
112
|
-
activejob (= 6.1.
|
113
|
-
activemodel (= 6.1.
|
114
|
-
activerecord (= 6.1.
|
115
|
-
activestorage (= 6.1.
|
116
|
-
activesupport (= 6.1.
|
111
|
+
rails (6.1.6)
|
112
|
+
actioncable (= 6.1.6)
|
113
|
+
actionmailbox (= 6.1.6)
|
114
|
+
actionmailer (= 6.1.6)
|
115
|
+
actionpack (= 6.1.6)
|
116
|
+
actiontext (= 6.1.6)
|
117
|
+
actionview (= 6.1.6)
|
118
|
+
activejob (= 6.1.6)
|
119
|
+
activemodel (= 6.1.6)
|
120
|
+
activerecord (= 6.1.6)
|
121
|
+
activestorage (= 6.1.6)
|
122
|
+
activesupport (= 6.1.6)
|
117
123
|
bundler (>= 1.15.0)
|
118
|
-
railties (= 6.1.
|
124
|
+
railties (= 6.1.6)
|
119
125
|
sprockets-rails (>= 2.0.0)
|
120
126
|
rails-dom-testing (2.0.3)
|
121
127
|
activesupport (>= 4.2.0)
|
122
128
|
nokogiri (>= 1.6)
|
123
129
|
rails-html-sanitizer (1.4.2)
|
124
130
|
loofah (~> 2.3)
|
125
|
-
railties (6.1.
|
126
|
-
actionpack (= 6.1.
|
127
|
-
activesupport (= 6.1.
|
131
|
+
railties (6.1.6)
|
132
|
+
actionpack (= 6.1.6)
|
133
|
+
activesupport (= 6.1.6)
|
128
134
|
method_source
|
129
|
-
rake (>=
|
135
|
+
rake (>= 12.2)
|
130
136
|
thor (~> 1.0)
|
131
137
|
rainbow (3.0.0)
|
132
138
|
rake (13.0.6)
|
@@ -148,31 +154,35 @@ GEM
|
|
148
154
|
rubocop-ast (>= 0.4.0)
|
149
155
|
ruby-progressbar (1.11.0)
|
150
156
|
semantic_range (3.0.0)
|
151
|
-
sprockets (4.0.
|
157
|
+
sprockets (4.0.3)
|
152
158
|
concurrent-ruby (~> 1.0)
|
153
159
|
rack (> 1, < 3)
|
154
|
-
sprockets-rails (3.
|
155
|
-
actionpack (>=
|
156
|
-
activesupport (>=
|
160
|
+
sprockets-rails (3.4.2)
|
161
|
+
actionpack (>= 5.2)
|
162
|
+
activesupport (>= 5.2)
|
157
163
|
sprockets (>= 3.0.0)
|
158
|
-
thor (1.1
|
164
|
+
thor (1.2.1)
|
159
165
|
tzinfo (2.0.4)
|
160
166
|
concurrent-ruby (~> 1.0)
|
161
167
|
unicode-display_width (2.1.0)
|
162
168
|
websocket-driver (0.7.5)
|
163
169
|
websocket-extensions (>= 0.1.0)
|
164
170
|
websocket-extensions (0.1.5)
|
165
|
-
zeitwerk (2.4
|
171
|
+
zeitwerk (2.5.4)
|
166
172
|
|
167
173
|
PLATFORMS
|
174
|
+
arm64-darwin-20
|
168
175
|
ruby
|
176
|
+
x86_64-darwin-20
|
177
|
+
x86_64-linux
|
169
178
|
|
170
179
|
DEPENDENCIES
|
171
180
|
bundler (>= 1.3.0)
|
172
181
|
byebug
|
173
182
|
minitest (~> 5.0)
|
183
|
+
nokogiri (~> 1.13, >= 1.13.6)
|
174
184
|
rack-proxy
|
175
|
-
rails
|
185
|
+
rails (>= 6.1.6)
|
176
186
|
rake (>= 11.1)
|
177
187
|
rubocop
|
178
188
|
rubocop-performance
|
data/README.md
CHANGED
@@ -83,8 +83,8 @@ Discussion forum and Slack to discuss debugging and troubleshooting tips. Please
|
|
83
83
|
## Features
|
84
84
|
- Rails view helpers that fully support Webpack output, including HMR and code splitting.
|
85
85
|
- Convenient but not required webpack configuration. The only requirement is that your webpack configuration create a manifest.
|
86
|
-
- HMR with the webpack-dev-server, such as for hot-reloading
|
87
|
-
- Automatic code splitting using multiple entry points to optimize JavaScript downloads
|
86
|
+
- HMR with the webpack-dev-server, such as for hot-reloading React!
|
87
|
+
- Automatic code splitting using multiple entry points to optimize JavaScript downloads.
|
88
88
|
- [Webpack v5+](https://webpack.js.org/)
|
89
89
|
- ES6 with [babel](https://babeljs.io/), [SWC](https://swc.rs/), or [Esbuild](https://github.com/privatenumber/esbuild-loader)
|
90
90
|
- Asset compression, source-maps, and minification
|
@@ -100,7 +100,6 @@ Discussion forum and Slack to discuss debugging and troubleshooting tips. Please
|
|
100
100
|
|
101
101
|
## Installation
|
102
102
|
|
103
|
-
|
104
103
|
### Rails v6+
|
105
104
|
|
106
105
|
With Rails v6+, skip JavaScript for a new app and follow below Manual Installation Steps to manually add the `shakapacker` gem to your Gemfile.
|
@@ -129,7 +128,7 @@ When `package.json` and/or `yarn.lock` changes, such as when pulling down change
|
|
129
128
|
yarn
|
130
129
|
```
|
131
130
|
|
132
|
-
Note, in v6
|
131
|
+
Note, in v6+, most JS packages are peer dependencies. Thus, the installer will add the packages:
|
133
132
|
|
134
133
|
```bash
|
135
134
|
yarn add @babel/core @babel/plugin-transform-runtime @babel/preset-env @babel/runtime babel-loader \
|
@@ -140,40 +139,70 @@ yarn add @babel/core @babel/plugin-transform-runtime @babel/preset-env @babel/ru
|
|
140
139
|
Previously, these "webpack" and "babel" packages were direct dependencies for `webpacker`. By
|
141
140
|
making these peer dependencies, you have control over the versions used in your webpack and babel configs.
|
142
141
|
|
143
|
-
### Note for Sprockets usage
|
144
|
-
|
145
|
-
If you are still using Sprockets for some of your assets, you might want to include files from `node_modules` directory in your asset pipeline. This is useful, for example, if you want to reference a stylesheet from a node package in your `.scss` stylesheet.
|
146
|
-
|
147
|
-
In order to enable this, make sure you add `node_modules` to the asset load path by adding the following in an initializer (for example `config/initializers/assets.rb`)
|
148
|
-
```ruby
|
149
|
-
Rails.application.config.assets.paths << Rails.root.join('node_modules')
|
150
|
-
```
|
151
|
-
|
152
142
|
### Note for Yarn v2 usage
|
153
143
|
|
154
144
|
If you are using Yarn v2 (berry), please note that PnP modules are not supported.
|
155
145
|
|
156
146
|
In order to use Shakapacker with Yarn v2, make sure you set `nodeLinker: node-modules` in your `.yarnrc.yml` file as per the [Yarn docs](https://yarnpkg.com/getting-started/migration#step-by-step) to opt out of Plug'n'Play behaviour.
|
157
147
|
|
148
|
+
## Concepts
|
149
|
+
|
150
|
+
At it's core, Shakapacker's essential functionality is to:
|
151
|
+
|
152
|
+
1. Provide configuration by a single file used by both Rails view helpers and JavaScript webpack compilation code.
|
153
|
+
2. Provide Rails view helpers, utilizing this configuration file, so that a webpage can load JavaScript, CSS, and other static assets compiled by webpack, supporting bundle splitting, fingerprinting, and HMR.
|
154
|
+
3. Provide a community supported, default webpack compilation that generates the necessary bundles and manifest, using the same configuration file. This compilation can be extended for any needs.
|
155
|
+
|
158
156
|
## Usage
|
159
157
|
|
160
|
-
###
|
158
|
+
### Configuration and Code
|
161
159
|
|
162
|
-
|
160
|
+
You will need your file system to correspond to the setup of your `webpacker.yml` file.
|
163
161
|
|
162
|
+
Suppose you have the following configuration:
|
163
|
+
|
164
|
+
`webacker.yml`
|
164
165
|
```yml
|
166
|
+
default: &default
|
167
|
+
source_path: app/javascript
|
168
|
+
source_entry_path: packs
|
169
|
+
public_root_path: public
|
170
|
+
public_output_path: packs
|
171
|
+
nested_entries: false
|
172
|
+
# And more
|
173
|
+
```
|
174
|
+
|
175
|
+
And that maps to a directory structure like this:
|
176
|
+
|
177
|
+
```
|
165
178
|
app/javascript:
|
166
|
-
#
|
167
|
-
└── application.js
|
168
|
-
└── application.css
|
169
|
-
└── src:
|
179
|
+
└── packs: # sets up webpack entries
|
180
|
+
│ └── application.js # references ../src/my_component.js
|
181
|
+
│ └── application.css
|
182
|
+
└── src: # any directory name is fine. Referenced files need to be under source_path
|
170
183
|
│ └── my_component.js
|
171
184
|
└── stylesheets:
|
172
185
|
│ └── my_styles.css
|
173
186
|
└── images:
|
174
187
|
└── logo.svg
|
188
|
+
public/packs # webpack output
|
175
189
|
```
|
176
190
|
|
191
|
+
Webpack intelligently includes only necessary files. In this example, the file `packs/application.js` would reference `../src/my_component.js`
|
192
|
+
|
193
|
+
`nested_entries` allows you to have webpack entry points nested in subdirectories. This defaults to false so you don't accidentally create entry points for an entire tree of files. In other words, with `nested_entries: false`, you can have your entire `source_path` used for your source (using the `source_entry_path: /`) and you place files at the top level that you want as entry points. `nested_entries: true` allows you to have entries that are in subdirectories. This is useful if you have entries that are generated, so you can have a `generated` subdirectory and easily separate generated files from the rest of your codebase.
|
194
|
+
|
195
|
+
### View Helpers
|
196
|
+
The Shakapacker view helpers generate the script and link tags to get the webpack output onto your views.
|
197
|
+
|
198
|
+
Be sure to consult the API documentation in the source code of [helper.rb](./lib/webpacker/helper.rb).
|
199
|
+
|
200
|
+
**Note:** In order for your styles or static assets files to be available in your view, you would need to link them in your "pack" or entry file. Otherwise, Webpack won't know to package up those files.
|
201
|
+
|
202
|
+
#### View Helpers `javascript_pack_tag` and `stylesheet_pack_tag`
|
203
|
+
|
204
|
+
These view helpers take your `webpacker.yml` configuration file, along with the resulting webpack compilation `manifest.json` and generates the HTML to load the assets.
|
205
|
+
|
177
206
|
You can then link the JavaScript pack in Rails views using the `javascript_pack_tag` helper. If you have styles imported in your pack file, you can link them by using `stylesheet_pack_tag`:
|
178
207
|
|
179
208
|
```erb
|
@@ -184,11 +213,14 @@ You can then link the JavaScript pack in Rails views using the `javascript_pack_
|
|
184
213
|
The `javascript_pack_tag` and `stylesheet_pack_tag` helpers will include all the transpiled
|
185
214
|
packs with the chunks in your view, which creates html tags for all the chunks.
|
186
215
|
|
187
|
-
|
216
|
+
You can provide multiple packs and other attributes. Note, `defer` defaults to showing.
|
188
217
|
|
189
218
|
```erb
|
190
219
|
<%= javascript_pack_tag 'calendar', 'map', 'data-turbolinks-track': 'reload' %>
|
220
|
+
```
|
191
221
|
|
222
|
+
The resulting HTML would look like:
|
223
|
+
```
|
192
224
|
<script src="/packs/vendor-16838bab065ae1e314.js" data-turbolinks-track="reload" defer></script>
|
193
225
|
<script src="/packs/calendar~runtime-16838bab065ae1e314.js" data-turbolinks-track="reload" defer></script>
|
194
226
|
<script src="/packs/calendar-1016838bab065ae1e314.js" data-turbolinks-track="reload" defer"></script>
|
@@ -196,61 +228,100 @@ The result looks like this:
|
|
196
228
|
<script src="/packs/map-16838bab065ae1e314.js" data-turbolinks-track="reload" defer></script>
|
197
229
|
```
|
198
230
|
|
199
|
-
|
231
|
+
In this output, both the calendar and map codes might refer to other common libraries. Those get placed something like the vendor bundle. The view helper removes any duplication.
|
232
|
+
|
233
|
+
Note, the default of "defer" for the `javascript_pack_tag`. You can override that to `false`. If you expose jquery globally with `expose-loader,` by using `import $ from "expose-loader?exposes=$,jQuery!jquery"` in your `app/javascript/application.js`, pass the option `defer: false` to your `javascript_pack_tag`.
|
234
|
+
|
235
|
+
**Important:** Pass all your pack names as multiple arguments, not multiple calls, when using `javascript_pack_tag` and the `stylesheet_pack_tag`. Otherwise, you will get duplicated chunks on the page.
|
200
236
|
|
201
237
|
```erb
|
202
238
|
<%# DO %>
|
203
239
|
<%= javascript_pack_tag 'calendar', 'map' %>
|
204
|
-
<%= stylesheet_pack_tag 'calendar', 'map' %>
|
205
240
|
|
206
241
|
<%# DON'T %>
|
207
242
|
<%= javascript_pack_tag 'calendar' %>
|
208
243
|
<%= javascript_pack_tag 'map' %>
|
209
|
-
<%= stylesheet_pack_tag 'calendar' %>
|
210
|
-
<%= stylesheet_pack_tag 'map' %>
|
211
244
|
```
|
212
|
-
|
213
|
-
However, you may use multiple calls to stylesheet_pack_tag if, say, you require multiple <style> tags for different output media:
|
245
|
+
While this also generally applies to `stylesheet_pack_tag`, you may use multiple calls to stylesheet_pack_tag if, say, you require multiple <style> tags for different output media:
|
214
246
|
|
215
247
|
``` erb
|
216
248
|
<%= stylesheet_pack_tag 'application', media: 'screen' %>
|
217
249
|
<%= stylesheet_pack_tag 'print', media: 'print' %>
|
218
250
|
```
|
219
251
|
|
220
|
-
|
252
|
+
#### View Helper `append_javascript_pack_tag`
|
221
253
|
|
254
|
+
If you need configure your pack names from the view for a route or partials, then you will need some logic to ensure you call the helpers only once with multiple arguments. The new view helper `append_javascript_pack_tag` can solve this problem. This helper will queue up packs when the `javascript_pack_tag` is finally used.
|
255
|
+
|
256
|
+
Main view:
|
257
|
+
```erb
|
258
|
+
<% append_javascript_pack_tag 'calendar' %>
|
259
|
+
```
|
260
|
+
|
261
|
+
Some partial:
|
262
|
+
```erb
|
263
|
+
<% append_javascript_pack_tag 'map' %>
|
264
|
+
```
|
265
|
+
|
266
|
+
And the main layout has:
|
222
267
|
```erb
|
223
|
-
<% append_javascript_pack_tag 'calendar', 'map' %>
|
224
268
|
<%= javascript_pack_tag 'application' %>
|
225
269
|
```
|
226
270
|
|
227
|
-
|
271
|
+
is the same as using this in the main layout:
|
272
|
+
|
273
|
+
```erb
|
274
|
+
<%= javascript_pack_tag 'calendar', 'map', application' %>
|
275
|
+
```
|
276
|
+
|
277
|
+
However, you typically can't do that in the main layout, as the view and partial codes will depend on the route.
|
278
|
+
|
279
|
+
Thus, you can distribute the logic of what packs are needed for any route. All the magic of splitting up the code was automatic!
|
280
|
+
|
281
|
+
**Important:** `append_javascript_pack_tag` can be used anywhere in your application as long as it is executed BEFORE the `javascript_pack_tag`. If you attempt to call `append_javascript_pack_tag` helper after `javascript_pack_tag`, an error will be raised. You should have only a single `javascript_pack_tag` invocation in your page load.
|
282
|
+
|
283
|
+
The typical issue is that your layout might reference some partials that need to configure packs. A good way to solve this problem is to use `content_for` to ensure that the code to render your partial comes before the call to `javascript_pack_tag`.
|
284
|
+
|
285
|
+
```erb
|
286
|
+
<% content_for :footer do
|
287
|
+
render 'shared/footer' %>
|
288
|
+
|
289
|
+
<%= javascript_pack_tag %>
|
228
290
|
|
229
|
-
|
291
|
+
<%= content_for :footer %>
|
292
|
+
```
|
230
293
|
|
231
294
|
For alternative options of setting the additional packs, [see this discussion](https://github.com/shakacode/shakapacker/issues/39).
|
232
295
|
|
296
|
+
#### View Helper: `asset_pack_path`
|
297
|
+
|
233
298
|
If you want to link a static asset for `<img />` tag, you can use the `asset_pack_path` helper:
|
234
299
|
```erb
|
235
300
|
<img src="<%= asset_pack_path 'static/logo.svg' %>" />
|
236
301
|
```
|
237
302
|
|
303
|
+
#### View Helper: `image_pack_tag`
|
304
|
+
|
238
305
|
Or use the dedicated helper:
|
239
306
|
```erb
|
240
307
|
<%= image_pack_tag 'application.png', size: '16x10', alt: 'Edit Entry' %>
|
241
308
|
<%= image_pack_tag 'picture.png', srcset: { 'picture-2x.png' => '2x' } %>
|
242
309
|
```
|
243
310
|
|
311
|
+
#### View Helper: `favicon_pack_tag`
|
244
312
|
If you want to create a favicon:
|
245
313
|
```erb
|
246
314
|
<%= favicon_pack_tag 'mb-icon.png', rel: 'apple-touch-icon', type: 'image/png' %>
|
247
315
|
```
|
248
316
|
|
317
|
+
#### View Helper: `preload_pack_asset`
|
249
318
|
If you want to preload a static asset in your `<head>`, you can use the `preload_pack_asset` helper:
|
250
319
|
```erb
|
251
320
|
<%= preload_pack_asset 'fonts/fa-regular-400.woff2' %>
|
252
321
|
```
|
253
322
|
|
323
|
+
|
324
|
+
### Images in Stylesheets
|
254
325
|
If you want to use images in your stylesheets:
|
255
326
|
|
256
327
|
```css
|
@@ -258,24 +329,39 @@ If you want to use images in your stylesheets:
|
|
258
329
|
background-image: url('../images/logo.svg')
|
259
330
|
}
|
260
331
|
```
|
261
|
-
### Defer for `javascript_pack_tag`
|
262
|
-
Note, the default of "defer" for the `javascript_pack_tag`. You can override that to `false`. If you expose jquery globally with `expose-loader,` by using `import $ from "expose-loader?exposes=$,jQuery!jquery"` in your `app/javascript/application.js`, pass the option `defer: false` to your `javascript_pack_tag`.
|
263
332
|
|
264
333
|
### Server-Side Rendering (SSR)
|
265
334
|
|
266
335
|
Note, if you are using server-side rendering of JavaScript with dynamic code-splitting, as is often done with extensions to Webpacker, like [React on Rails](https://github.com/shakacode/react_on_rails), your JavaScript should create the link prefetch HTML tags that you will use, so you won't need to use to `asset_pack_path` in those circumstances.
|
267
336
|
|
268
|
-
**Note:** In order for your styles or static assets files to be available in your view, you would need to link them in your "pack" or entry file. Otherwise, Webpack won't know to package up those files.
|
269
|
-
|
270
337
|
### Development
|
271
338
|
|
272
339
|
Webpacker ships with two binstubs: `./bin/webpacker` and `./bin/webpacker-dev-server`. Both are thin wrappers around the standard `webpack.js` and `webpack-dev-server.js` executables to ensure that the right configuration files and environmental variables are loaded based on your environment.
|
273
340
|
|
274
|
-
|
341
|
+
#### Automatic Webpack Code Building
|
342
|
+
|
343
|
+
Shakapacker can be configured to automatically compile on demand when needed using the `webpacker.yml` `compile` option. This happens when you refer to any of the pack assets using the Shakapacker helper methods. This means that you don't have to run any separate processes. Compilation errors are logged to the standard Rails log. However, this auto-compilation happens when a web request is made that requires an updated webpack build, not when files change. Thus, that can be **painfully slow** for front-end development in this default way. Instead, you should either run the `bin/webpacker --watch` or run `./bin/webpacker-dev-server` during development.
|
344
|
+
|
345
|
+
The `compile: true` option can be more useful for test and production builds.
|
346
|
+
|
347
|
+
#### Compiler strategies
|
348
|
+
|
349
|
+
Shakapacker ships with two different strategies that are used to determine whether assets need recompilation per the `compile: true` option:
|
350
|
+
|
351
|
+
- `digest` - This strategy calculates SHA1 digest of files in your watched paths (see below). The calculated digest is then stored in a temp file. To check whether the assets need to be recompiled, Shakapacker calculates the SHA1 of the watched files and compares it with the one stored. If the digests are equal, no recompilation occurs. If the digests are different or the temp file is missing, files are recompiled.
|
352
|
+
- `mtime` - This strategy looks at last modified at timestamps of both files AND directories in your watched paths. The timestamp of the most recent file or directory is then compared with the timestamp of `manifest.json` file generated. If the manifest file timestamp is newer than one of the most recently modified file or directory in the watched paths, no recompilation occurs. If the manifest file is order, files are recompiled.
|
353
|
+
|
354
|
+
The `mtime` strategy is generally faster than the `digest` one, but it requires stable timestamps, this makes it perfect for a development environment, such as needing to rebuild bundles for tests, or if you're not changing frontend assets much.
|
275
355
|
|
276
|
-
|
356
|
+
In production or CI environments, the `digest` strategy is more suitable, unless you are using incremental builds or caching and can guarantee that the timestamps will not change after e.g. cache restore. However, many production or CI environments will explicitly compile assets, so `compile: false` is more appropriate. Otherwise, you'll waste time either checking file timestamps or computing digests.
|
277
357
|
|
278
|
-
|
358
|
+
You can control what strategy is used by `compiler_strategy` option in `webpacker.yml` config file. By default `mtime` strategy is used in development environment, `digest` is used elsewhere.
|
359
|
+
|
360
|
+
**Note:** If you are not using the webpack-dev-server, your packs will be served by Rails public file server. If you've enabled caching (Rails application `config.action_controller.perform_caching` setting), your changes will likely not be picked up due to `Cache-Control` header being set and assets being cached in browser memory. For more details see the [issue #88](https://github.com/shakacode/shakapacker/issues/88).
|
361
|
+
|
362
|
+
If you want to use live code reloading, or you have enough JavaScript that on-demand compilation is too slow, you'll need to run `./bin/webpacker-dev-server`. This process will watch for changes in the relevant files, defined by `webpacker.yml` configuration settings for `source_path`, `source_entry_path`, and `additional_paths`, and it will then automatically reload the browser to match. This feature is also known as [Hot Module Replacement](https://webpack.js.org/concepts/hot-module-replacement/).
|
363
|
+
|
364
|
+
#### Common Development Commands
|
279
365
|
|
280
366
|
```bash
|
281
367
|
# webpack dev server
|
@@ -286,15 +372,6 @@ If you want to use live code reloading, or you have enough JavaScript that on-de
|
|
286
372
|
|
287
373
|
# standalone build
|
288
374
|
./bin/webpacker --progress
|
289
|
-
|
290
|
-
# Help
|
291
|
-
./bin/webpacker help
|
292
|
-
|
293
|
-
# Version
|
294
|
-
./bin/webpacker version
|
295
|
-
|
296
|
-
# Info
|
297
|
-
./bin/webpacker info
|
298
375
|
```
|
299
376
|
|
300
377
|
Once you start this webpack development server, Webpacker will automatically start proxying all webpack asset requests to this server. When you stop this server, Rails will detect that it's not running and Rails will revert back to on-demand compilation _if_ you have the `compile` option set to true in your `config/webpacker.yml`
|
@@ -327,7 +404,7 @@ end
|
|
327
404
|
First, you don't _need_ to use Shakapacker's webpack configuration. However, the `shakapacker` NPM package provides convenient access to configuration code that reads the `config/webpacker.yml` file which the view helpers also use. If you have your own customized webpack configuration, at the minimum, you must ensure:
|
328
405
|
|
329
406
|
1. Your output files go the right directory
|
330
|
-
2.
|
407
|
+
2. Your output includes a manifest, via package [`webpack-assets-manifest`](https://github.com/webdeveric/webpack-assets-manifest) that maps output names (your 'packs') to the fingerprinted versions, including bundle-splitting dependencies. That's the main secret sauce of webpacker!
|
331
408
|
|
332
409
|
The most practical webpack configuration is to take the default from Shakapacker and then use [webpack-merge](https://github.com/survivejs/webpack-merge) to merge your customizations with the default. For example, suppose you want to add some `resolve.extensions`:
|
333
410
|
|
@@ -350,7 +427,7 @@ module.exports = merge({}, baseWebpackConfig, options)
|
|
350
427
|
|
351
428
|
This example is based on [an example project](https://github.com/shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh/blob/master/config/webpack/webpack.config.js)
|
352
429
|
|
353
|
-
|
430
|
+
Shakapacker gives you a default configuration file `config/webpack/webpack.config.js`, which, by default, you don't need to make any changes to `config/webpack/webpack.config.js` since it's a standard production-ready configuration. However, you will probably want to customize or add a new loader by modifying the webpack configuration, as shown above.
|
354
431
|
|
355
432
|
You might add separate files to keep your code more organized.
|
356
433
|
|
@@ -380,7 +457,7 @@ const customConfig = require('./custom')
|
|
380
457
|
module.exports = merge(webpackConfig, customConfig)
|
381
458
|
```
|
382
459
|
|
383
|
-
If you need access to configs within
|
460
|
+
If you need access to configs within Shakapacker's configuration, you can import them like so:
|
384
461
|
|
385
462
|
```js
|
386
463
|
// config/webpack/webpack.config.js
|
@@ -402,7 +479,7 @@ svgRule.test = svgRule.test.filter(t => !t.test('.svg'))
|
|
402
479
|
|
403
480
|
### Babel configuration
|
404
481
|
|
405
|
-
By default, you will find the
|
482
|
+
By default, you will find the Shakapacker preset in your `package.json`. Note, you need to use the new NPM package name, `shakapacker`.
|
406
483
|
|
407
484
|
```json
|
408
485
|
"babel": {
|
@@ -411,9 +488,9 @@ By default, you will find the Webpacker preset in your `package.json`. Note, you
|
|
411
488
|
]
|
412
489
|
},
|
413
490
|
```
|
414
|
-
|
415
491
|
Optionally, you can change your Babel configuration by removing these lines in your `package.json` and add [a Babel configuration file](https://babeljs.io/docs/en/config-files) in your project. For an example customization based on the original, see [Customizing Babel Config](./docs/customizing_babel_config.md).
|
416
492
|
|
493
|
+
|
417
494
|
### SWC configuration
|
418
495
|
|
419
496
|
You can try out experimental integration with the SWC loader. You can read more at [SWC usage docs](./docs/using_swc_loader.md).
|
@@ -428,7 +505,7 @@ Please note that if you want opt-in to use esbuild-loader, you can skip [React](
|
|
428
505
|
|
429
506
|
### Integrations
|
430
507
|
|
431
|
-
|
508
|
+
Shakapacker out of the box supports JS and static assets (fonts, images etc.) compilation. To enable support for CoffeeScript or TypeScript install relevant packages:
|
432
509
|
|
433
510
|
#### React
|
434
511
|
|
@@ -605,7 +682,7 @@ module.exports = merge(vueConfig, webpackConfig)
|
|
605
682
|
|
606
683
|
### Custom Rails environments
|
607
684
|
|
608
|
-
Out of the box
|
685
|
+
Out of the box Shakapacker ships with - development, test and production environments in `config/webpacker.yml` however, in most production apps extra environments are needed as part of deployment workflow. Shakapacker supports this out of the box from version 3.4.0+ onwards.
|
609
686
|
|
610
687
|
You can choose to define additional environment configurations in webpacker.yml,
|
611
688
|
|
@@ -623,7 +700,7 @@ staging:
|
|
623
700
|
public_output_path: packs-staging
|
624
701
|
```
|
625
702
|
|
626
|
-
Otherwise
|
703
|
+
Otherwise Shakapacker will use production environment as a fallback environment for loading configurations. Please note, `NODE_ENV` can either be set to `production`, `development` or `test`. This means you don't need to create additional environment files inside `config/webpacker/*` and instead use webpacker.yml to load different configurations using `RAILS_ENV`.
|
627
704
|
|
628
705
|
For example, the below command will compile assets in production mode but will use staging configurations from `config/webpacker.yml` if available or use fallback production environment configuration:
|
629
706
|
|
@@ -651,7 +728,7 @@ bundle exec rails webpacker:compile
|
|
651
728
|
|
652
729
|
### Upgrading
|
653
730
|
|
654
|
-
You can run following commands to upgrade
|
731
|
+
You can run following commands to upgrade Shakapacker to the latest stable version. This process involves upgrading the gem and related JavaScript packages:
|
655
732
|
|
656
733
|
```bash
|
657
734
|
# check your Gemfile for version restrictions
|
@@ -674,20 +751,9 @@ yarn add shakapacker@next
|
|
674
751
|
|
675
752
|
Also, consult the [CHANGELOG](./CHANGELOG.md) for additional upgrade links.
|
676
753
|
|
677
|
-
### Compiler strategies
|
678
|
-
|
679
|
-
Shakapacker ships with two different strategies that are used to determine whether assets need recompilation.
|
680
|
-
|
681
|
-
- `digest` - This strategy calculates SHA1 digest of files in your watched paths (see below). The calculated digest is then stored in a temp file. To check whether the assets need to be recompiled, Shakapacker calculates the SHA1 of the watched files and compares it with the one stored. If the digests are equal, no recompilation occurs. If the digests are different or the temp file is missing, files are recompiled.
|
682
|
-
- `mtime` - This strategy looks at last modified at timestamps of both files AND directories in your watched paths. The timestamp of the most recent file or directory is then compared with the timestamp of `manifest.json` file generated. If the manifest file timestamp is newer than one of the most recently modified file or directory in the watched paths, no recompilation occurs. If the manifest file is order, files are recompiled.
|
683
|
-
|
684
|
-
`mtime` strategy is generally faster than the `digest` one, but it requires stable timestamps, this makes it perfect for development environment. In production or CI environments, the `digest` strategy is more suitable, unless you are using incremental builds or caching and can guarantee that the timestamps will not change after e.g. cache restore.
|
685
|
-
|
686
|
-
You can control what strategy is used by `compiler_strategy` option in `webpacker.yml` config file. By default `mtime` strategy is used in development environment, `digest` is used elsewhere.
|
687
|
-
|
688
754
|
### Paths
|
689
755
|
|
690
|
-
By default,
|
756
|
+
By default, Shakapacker ships with simple conventions for where the JavaScript app files and compiled webpack bundles will go in your Rails app. All these options are configurable from `config/webpacker.yml` file.
|
691
757
|
|
692
758
|
The configuration for what webpack is supposed to compile by default rests on the convention that every file in `app/javascript/`**(default)** or whatever path you set for `source_entry_path` in the `webpacker.yml` configuration is turned into their own output files (or entry points, as webpack calls it). Therefore you don't want to put any file inside `app/javascript` directory that you do not want to be an entry file. As a rule of thumb, put all files you want to link in your views inside "app/javascript/" directory and keep everything else under subdirectories like `app/javascript/controllers`.
|
693
759
|
|
@@ -715,7 +781,7 @@ If you want to have HMR and separate link tags, set `hmr: true` and `inline_css:
|
|
715
781
|
|
716
782
|
### Additional paths
|
717
783
|
|
718
|
-
If you are adding
|
784
|
+
If you are adding Shakapacker to an existing app that has most of the assets inside `app/assets` or inside an engine, and you want to share that with webpack modules, you can use the `additional_paths` option available in `config/webpacker.yml`. This lets you
|
719
785
|
add additional paths that webpack should look up when resolving modules:
|
720
786
|
|
721
787
|
```yml
|
@@ -732,12 +798,12 @@ import 'images/rails.png'
|
|
732
798
|
|
733
799
|
**Note:** Please be careful when adding paths here otherwise it will make the compilation slow, consider adding specific paths instead of whole parent directory if you just need to reference one or two modules
|
734
800
|
|
735
|
-
**Also note:** While importing assets living outside your `source_path` defined in webpacker.yml (like, for instance, assets under `app/assets`) from within your packs using _relative_ paths like `import '../../assets/javascripts/file.js'` will work in development,
|
801
|
+
**Also note:** While importing assets living outside your `source_path` defined in webpacker.yml (like, for instance, assets under `app/assets`) from within your packs using _relative_ paths like `import '../../assets/javascripts/file.js'` will work in development, Shakapacker won't recompile the bundle in production unless a file that lives in one of it's watched paths has changed (check out `Webpacker::MtimeStrategy#latest_modified_timestamp` or `Webpacker::DigestStrategy#watched_files_digest` depending on strategy configured by `compiler_strategy` option in `webpacker.yml`). That's why you'd need to add `app/assets` to the additional_paths as stated above and use `import 'javascripts/file.js'` instead.
|
736
802
|
|
737
803
|
|
738
804
|
## Deployment
|
739
805
|
|
740
|
-
|
806
|
+
Shakapacker hooks up a new `webpacker:compile` task to `assets:precompile`, which gets run whenever you run `assets:precompile`. If you are not using Sprockets, `webpacker:compile` is automatically aliased to `assets:precompile`. Similar to sprockets both rake tasks will compile packs in production mode but will use `RAILS_ENV` to load configuration from `config/webpacker.yml` (if available).
|
741
807
|
|
742
808
|
This behavior is optional & can be disabled by either setting an `WEBPACKER_PRECOMPILE` environment variable to `false`, `no`, `n`, or `f`, or by setting a `webpacker_precompile` key in your `webpacker.yml` to `false`. ([source code](./lib/webpacker/configuration.rb#L30))
|
743
809
|
|
@@ -760,3 +826,15 @@ We encourage you to contribute to Shakapacker/Webpacker! See [CONTRIBUTING](CONT
|
|
760
826
|
## License
|
761
827
|
|
762
828
|
Webpacker is released under the [MIT License](https://opensource.org/licenses/MIT).
|
829
|
+
|
830
|
+
# Supporters
|
831
|
+
|
832
|
+
The following companies support this open source project, and ShakaCode uses their products! Justin writes React on Rails on [RubyMine](https://www.jetbrains.com/ruby/). We use [Scout](https://scoutapp.com/) to monitor the live performance of [HiChee.com](https://HiChee.com), [Rails AutoScale](https://railsautoscale.com) to scale the dynos of HiChee, and [HoneyBadger](https://www.honeybadger.io/) to monitor application errors. We love [BrowserStack](https://www.browserstack.com) to solve problems with oddball browsers.
|
833
|
+
|
834
|
+
[![RubyMine](https://user-images.githubusercontent.com/1118459/114100597-3b0e3000-9860-11eb-9b12-73beb1a184b2.png)](https://www.jetbrains.com/ruby/)
|
835
|
+
[![Scout](https://user-images.githubusercontent.com/1118459/171088197-81555b69-9ed0-4235-9acf-fcb37ecfb949.png)](https://scoutapp.com/)
|
836
|
+
[![Rails AutoScale](https://user-images.githubusercontent.com/1118459/103197530-48dc0e80-488a-11eb-8b1b-a16664b30274.png)](https://railsautoscale.com/)
|
837
|
+
[![BrowserStack](https://cloud.githubusercontent.com/assets/1118459/23203304/1261e468-f886-11e6-819e-93b1a3f17da4.png)](https://www.browserstack.com)
|
838
|
+
[![HoneyBadger](https://user-images.githubusercontent.com/1118459/114100696-63962a00-9860-11eb-8ac1-75ca02856d8e.png)](https://www.honeybadger.io/)
|
839
|
+
|
840
|
+
ShakaCode's favorite project tracking tool is [Shortcut](https://shortcut.com/). If you want to **try Shortcut and get 2 months free beyond the 14-day trial period**, click [here to use ShakaCode's referral code](http://r.clbh.se/mvfoNeH). We're participating in their awesome triple-sided referral program, which you can read about [here](https://shortcut.com/referral/). By using our [referral code](http://r.clbh.se/mvfoNeH) you'll be supporting ShakaCode and, thus, React on Rails!
|
data/docs/sprockets.md
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# Sprockets
|
2
|
+
|
3
|
+
### Note for Sprockets usage
|
4
|
+
|
5
|
+
If you are still using Sprockets for some of your assets, you might want to include files from `node_modules` directory in your asset pipeline. This is useful, for example, if you want to reference a stylesheet from a node package in your `.scss` stylesheet.
|
6
|
+
|
7
|
+
In order to enable this, make sure you add `node_modules` to the asset load path by adding the following in an initializer (for example `config/initializers/assets.rb`)
|
8
|
+
```ruby
|
9
|
+
Rails.application.config.assets.paths << Rails.root.join('node_modules')
|
10
|
+
```
|
@@ -2,7 +2,15 @@
|
|
2
2
|
|
3
3
|
default: &default
|
4
4
|
source_path: app/javascript
|
5
|
+
|
6
|
+
# You can have a subdirectory of the source_path, like 'packs' (recommended).
|
7
|
+
# Alternatively, you can use '/' to use the whole source_path directory.
|
5
8
|
source_entry_path: /
|
9
|
+
|
10
|
+
# If nested_entries is true, then we'll pick up subdirectories within the source_entry_path.
|
11
|
+
# You cannot set this option to true if you set source_entry_path to '/'
|
12
|
+
nested_entries: false
|
13
|
+
|
6
14
|
public_root_path: public
|
7
15
|
public_output_path: packs
|
8
16
|
cache_path: tmp/webpacker
|
@@ -1,16 +1,8 @@
|
|
1
1
|
$stdout.sync = true
|
2
2
|
|
3
|
-
def yarn_install_available?
|
4
|
-
rails_major = Rails::VERSION::MAJOR
|
5
|
-
rails_minor = Rails::VERSION::MINOR
|
6
|
-
|
7
|
-
rails_major > 5 || (rails_major == 5 && rails_minor >= 1)
|
8
|
-
end
|
9
|
-
|
10
3
|
def enhance_assets_precompile
|
11
4
|
# yarn:install was added in Rails 5.1
|
12
|
-
|
13
|
-
Rake::Task["assets:precompile"].enhance(deps) do |task|
|
5
|
+
Rake::Task["assets:precompile"].enhance do |task|
|
14
6
|
prefix = task.name.split(/#|assets:precompile/).first
|
15
7
|
|
16
8
|
Rake::Task["#{prefix}webpacker:compile"].invoke
|
@@ -37,6 +29,6 @@ if Webpacker.config.webpacker_precompile?
|
|
37
29
|
if Rake::Task.task_defined?("assets:precompile")
|
38
30
|
enhance_assets_precompile
|
39
31
|
else
|
40
|
-
Rake::Task.define_task("assets:precompile" => ["webpacker:
|
32
|
+
Rake::Task.define_task("assets:precompile" => ["webpacker:compile"])
|
41
33
|
end
|
42
34
|
end
|
data/lib/tasks/webpacker.rake
CHANGED
@@ -9,7 +9,6 @@ tasks = {
|
|
9
9
|
"webpacker:check_binstubs" => "Verifies that bin/webpacker is present",
|
10
10
|
"webpacker:binstubs" => "Installs Webpacker binstubs in this application",
|
11
11
|
"webpacker:verify_install" => "Verifies if Webpacker is installed",
|
12
|
-
"webpacker:yarn_install" => "Support for older Rails versions. Install all JavaScript dependencies as specified via Yarn"
|
13
12
|
}.freeze
|
14
13
|
|
15
14
|
desc "Lists all available tasks in Webpacker"
|
@@ -30,7 +30,10 @@ class Webpacker::Configuration
|
|
30
30
|
def webpacker_precompile?
|
31
31
|
# ENV of false takes precedence
|
32
32
|
return false if %w(no false n f).include?(ENV["WEBPACKER_PRECOMPILE"])
|
33
|
-
return %w(yes true t).include?(ENV["WEBPACKER_PRECOMPILE"])
|
33
|
+
return true if %w(yes true t).include?(ENV["WEBPACKER_PRECOMPILE"])
|
34
|
+
|
35
|
+
return false unless config_path.exist?
|
36
|
+
fetch(:webpacker_precompile)
|
34
37
|
end
|
35
38
|
|
36
39
|
def source_path
|
data/lib/webpacker/version.rb
CHANGED
@@ -3,15 +3,18 @@
|
|
3
3
|
// environment.js expects to find config/webpacker.yml and resolved modules from
|
4
4
|
// the root of a Rails project
|
5
5
|
|
6
|
-
const { chdirTestApp, chdirCwd } = require('../../utils/helpers')
|
6
|
+
const { chdirTestApp, chdirCwd, resetEnv } = require('../../utils/helpers')
|
7
7
|
|
8
8
|
chdirTestApp()
|
9
9
|
|
10
10
|
const { resolve } = require('path')
|
11
|
-
|
11
|
+
|
12
12
|
const baseConfig = require('../base')
|
13
|
+
const config = require("../../config");
|
13
14
|
|
14
15
|
describe('Base config', () => {
|
16
|
+
beforeEach(() => jest.resetModules() && resetEnv())
|
17
|
+
|
15
18
|
afterAll(chdirCwd)
|
16
19
|
|
17
20
|
describe('config', () => {
|
@@ -21,11 +24,33 @@ describe('Base config', () => {
|
|
21
24
|
)
|
22
25
|
})
|
23
26
|
|
24
|
-
test('should return
|
27
|
+
test('should return only 2 entry points with config.nested_entries == false', () => {
|
28
|
+
expect(config.nested_entries).toEqual(false)
|
29
|
+
|
30
|
+
expect(baseConfig.entry.multi_entry.sort()).toEqual([
|
31
|
+
resolve('app', 'packs', 'entrypoints', 'multi_entry.css'),
|
32
|
+
resolve('app', 'packs', 'entrypoints', 'multi_entry.js')
|
33
|
+
])
|
34
|
+
expect(baseConfig.entry['generated/something']).toEqual(undefined)
|
35
|
+
})
|
36
|
+
|
37
|
+
test('should returns top level and nested entry points with config.nested_entries == true', () => {
|
38
|
+
process.env.WEBPACKER_CONFIG = 'config/webpacker_nested_entries.yml'
|
39
|
+
const config = require("../../config");
|
40
|
+
const baseConfig = require('../base')
|
41
|
+
|
42
|
+
expect(config.nested_entries).toEqual(true)
|
43
|
+
|
44
|
+
expect(baseConfig.entry.application).toEqual(
|
45
|
+
resolve('app', 'packs', 'entrypoints', 'application.js')
|
46
|
+
)
|
25
47
|
expect(baseConfig.entry.multi_entry.sort()).toEqual([
|
26
48
|
resolve('app', 'packs', 'entrypoints', 'multi_entry.css'),
|
27
49
|
resolve('app', 'packs', 'entrypoints', 'multi_entry.js')
|
28
50
|
])
|
51
|
+
expect(baseConfig.entry['generated/something']).toEqual(
|
52
|
+
resolve('app', 'packs', 'entrypoints', 'generated', 'something.js')
|
53
|
+
)
|
29
54
|
})
|
30
55
|
|
31
56
|
test('should return output', () => {
|
@@ -36,6 +61,8 @@ describe('Base config', () => {
|
|
36
61
|
})
|
37
62
|
|
38
63
|
test('should return default loader rules for each file in config/loaders', () => {
|
64
|
+
const rules = require('../../rules')
|
65
|
+
|
39
66
|
const defaultRules = Object.keys(rules)
|
40
67
|
const configRules = baseConfig.module.rules
|
41
68
|
|
@@ -14,8 +14,15 @@ const { moduleExists } = require('../utils/helpers')
|
|
14
14
|
const getEntryObject = () => {
|
15
15
|
const entries = {}
|
16
16
|
const rootPath = join(config.source_path, config.source_entry_path)
|
17
|
+
if (config.source_entry_path === '/' && config.nested_entries) {
|
18
|
+
throw new Error(
|
19
|
+
"Your webpacker config specified using a source_entry_path of '/' with 'nested_entries' == " +
|
20
|
+
"'true'. Doing this would result in packs for every one of your source files"
|
21
|
+
)
|
22
|
+
}
|
23
|
+
const nesting = config.nested_entries ? '**/' : ''
|
17
24
|
|
18
|
-
globSync(`${rootPath}
|
25
|
+
globSync(`${rootPath}/${nesting}*.*`).forEach((path) => {
|
19
26
|
const namespace = relative(join(rootPath), dirname(path))
|
20
27
|
const name = join(namespace, basename(path, extname(path)))
|
21
28
|
let assetPaths = resolve(path)
|
data/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "shakapacker",
|
3
|
-
"version": "6.
|
3
|
+
"version": "6.4.0",
|
4
4
|
"description": "Use webpack to manage app-like JavaScript modules in Rails",
|
5
5
|
"main": "package/index.js",
|
6
6
|
"files": [
|
@@ -17,7 +17,7 @@
|
|
17
17
|
"@babel/preset-env": "^7.16.11",
|
18
18
|
"@babel/runtime": "^7.17.9",
|
19
19
|
"babel-loader": "^8.2.4",
|
20
|
-
"compression-webpack-plugin": "^9.0.0",
|
20
|
+
"compression-webpack-plugin": "^9.0.0 || ^10.0.0",
|
21
21
|
"terser-webpack-plugin": "^5.3.1",
|
22
22
|
"webpack": "^5.72.0",
|
23
23
|
"webpack-assets-manifest": "^5.0.6",
|
data/test/rake_tasks_test.rb
CHANGED
@@ -30,42 +30,8 @@ class RakeTasksTest < Minitest::Test
|
|
30
30
|
refute_includes output, "Webpacker requires Yarn"
|
31
31
|
end
|
32
32
|
|
33
|
-
def test_rake_webpacker_yarn_install_in_non_production_environments
|
34
|
-
assert_includes test_app_dev_dependencies, "right-pad"
|
35
|
-
|
36
|
-
Webpacker.with_node_env("test") do
|
37
|
-
Dir.chdir(test_app_path) do
|
38
|
-
`bundle exec rake webpacker:yarn_install`
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
assert_includes installed_node_module_names, "right-pad",
|
43
|
-
"Expected dev dependencies to be installed"
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_rake_webpacker_yarn_install_in_production_environment
|
47
|
-
Webpacker.with_node_env("production") do
|
48
|
-
Dir.chdir(test_app_path) do
|
49
|
-
`bundle exec rake webpacker:yarn_install`
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
refute_includes installed_node_module_names, "right-pad",
|
54
|
-
"Expected only production dependencies to be installed"
|
55
|
-
end
|
56
|
-
|
57
33
|
private
|
58
34
|
def test_app_path
|
59
35
|
File.expand_path("test_app", __dir__)
|
60
36
|
end
|
61
|
-
|
62
|
-
def test_app_dev_dependencies
|
63
|
-
package_json = File.expand_path("package.json", test_app_path)
|
64
|
-
JSON.parse(File.read(package_json))["devDependencies"]
|
65
|
-
end
|
66
|
-
|
67
|
-
def installed_node_module_names
|
68
|
-
node_modules_path = File.expand_path("node_modules", test_app_path)
|
69
|
-
Dir.chdir(node_modules_path) { Dir.glob("*") }
|
70
|
-
end
|
71
37
|
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# Note: You must restart bin/webpacker-dev-server for changes to take effect
|
2
|
+
|
3
|
+
default: &default
|
4
|
+
source_path: app/packs
|
5
|
+
source_entry_path: entrypoints
|
6
|
+
nested_entries: true
|
7
|
+
public_root_path: public
|
8
|
+
public_output_path: packs
|
9
|
+
cache_path: tmp/webpacker
|
10
|
+
webpack_compile_output: false
|
11
|
+
webpack_loader: babel
|
12
|
+
|
13
|
+
# Location for manifest.json, defaults to {public_output_path}/manifest.json if unset
|
14
|
+
# manifest_path: public/packs/manifest.json
|
15
|
+
|
16
|
+
# Additional paths webpack should look up modules
|
17
|
+
# ['app/assets', 'engine/foo/app/assets']
|
18
|
+
additional_paths:
|
19
|
+
- app/assets
|
20
|
+
- /etc/yarn
|
21
|
+
- some.config.js
|
22
|
+
- app/elm
|
23
|
+
|
24
|
+
# Reload manifest.json on all requests so we reload latest compiled packs
|
25
|
+
cache_manifest: false
|
26
|
+
|
27
|
+
static_assets_extensions:
|
28
|
+
- .jpg
|
29
|
+
- .jpeg
|
30
|
+
- .png
|
31
|
+
- .gif
|
32
|
+
- .tiff
|
33
|
+
- .ico
|
34
|
+
- .svg
|
35
|
+
|
36
|
+
extensions:
|
37
|
+
- .mjs
|
38
|
+
- .js
|
39
|
+
|
40
|
+
development:
|
41
|
+
<<: *default
|
42
|
+
compile: true
|
43
|
+
ensure_consistent_versioning: true
|
44
|
+
|
45
|
+
# Reference: https://webpack.js.org/configuration/dev-server/
|
46
|
+
dev_server:
|
47
|
+
https: false
|
48
|
+
host: localhost
|
49
|
+
port: 3035
|
50
|
+
public: localhost:3035
|
51
|
+
hmr: false
|
52
|
+
overlay: true
|
53
|
+
disable_host_check: true
|
54
|
+
use_local_ip: false
|
55
|
+
pretty: false
|
56
|
+
|
57
|
+
test:
|
58
|
+
<<: *default
|
59
|
+
compile: true
|
60
|
+
|
61
|
+
# Compile test packs to a separate directory
|
62
|
+
public_output_path: packs-test
|
63
|
+
|
64
|
+
production:
|
65
|
+
<<: *default
|
66
|
+
|
67
|
+
# Production depends on precompilation of packs prior to booting for performance.
|
68
|
+
compile: false
|
69
|
+
|
70
|
+
# Cache manifest.json for performance
|
71
|
+
cache_manifest: true
|
72
|
+
|
73
|
+
staging:
|
74
|
+
<<: *default
|
75
|
+
|
76
|
+
# Production depends on precompilation of packs prior to booting for performance.
|
77
|
+
compile: false
|
78
|
+
|
79
|
+
# Cache manifest.json for performance
|
80
|
+
cache_manifest: true
|
81
|
+
|
82
|
+
# Compile staging packs to a separate directory
|
83
|
+
public_output_path: packs-staging
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shakapacker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-
|
13
|
+
date: 2022-06-03 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -143,6 +143,7 @@ files:
|
|
143
143
|
- docs/deployment.md
|
144
144
|
- docs/developing_webpacker.md
|
145
145
|
- docs/react.md
|
146
|
+
- docs/sprockets.md
|
146
147
|
- docs/style_loader_vs_mini_css.md
|
147
148
|
- docs/troubleshooting.md
|
148
149
|
- docs/using_esbuild_loader.md
|
@@ -177,8 +178,6 @@ files:
|
|
177
178
|
- lib/tasks/webpacker/install.rake
|
178
179
|
- lib/tasks/webpacker/verify_config.rake
|
179
180
|
- lib/tasks/webpacker/verify_install.rake
|
180
|
-
- lib/tasks/webpacker/yarn_install.rake
|
181
|
-
- lib/tasks/yarn.rake
|
182
181
|
- lib/webpacker.rb
|
183
182
|
- lib/webpacker/base_strategy.rb
|
184
183
|
- lib/webpacker/commands.rb
|
@@ -272,6 +271,7 @@ files:
|
|
272
271
|
- test/rake_tasks_test.rb
|
273
272
|
- test/test_app/Rakefile
|
274
273
|
- test/test_app/app/packs/entrypoints/application.js
|
274
|
+
- test/test_app/app/packs/entrypoints/generated/something.js
|
275
275
|
- test/test_app/app/packs/entrypoints/multi_entry.css
|
276
276
|
- test/test_app/app/packs/entrypoints/multi_entry.js
|
277
277
|
- test/test_app/bin/webpacker
|
@@ -283,6 +283,7 @@ files:
|
|
283
283
|
- test/test_app/config/webpack/webpack.config.js
|
284
284
|
- test/test_app/config/webpacker.yml
|
285
285
|
- test/test_app/config/webpacker_manifest_path.yml
|
286
|
+
- test/test_app/config/webpacker_nested_entries.yml
|
286
287
|
- test/test_app/config/webpacker_no_precompile.yml
|
287
288
|
- test/test_app/config/webpacker_other_location.yml
|
288
289
|
- test/test_app/config/webpacker_public_root.yml
|
@@ -300,7 +301,7 @@ homepage: https://github.com/shakacode/shakapacker
|
|
300
301
|
licenses:
|
301
302
|
- MIT
|
302
303
|
metadata:
|
303
|
-
source_code_uri: https://github.com/shakacode/shakapacker/tree/v6.
|
304
|
+
source_code_uri: https://github.com/shakacode/shakapacker/tree/v6.4.0
|
304
305
|
post_install_message:
|
305
306
|
rdoc_options: []
|
306
307
|
require_paths:
|
@@ -353,6 +354,7 @@ test_files:
|
|
353
354
|
- test/rake_tasks_test.rb
|
354
355
|
- test/test_app/Rakefile
|
355
356
|
- test/test_app/app/packs/entrypoints/application.js
|
357
|
+
- test/test_app/app/packs/entrypoints/generated/something.js
|
356
358
|
- test/test_app/app/packs/entrypoints/multi_entry.css
|
357
359
|
- test/test_app/app/packs/entrypoints/multi_entry.js
|
358
360
|
- test/test_app/bin/webpacker
|
@@ -364,6 +366,7 @@ test_files:
|
|
364
366
|
- test/test_app/config/webpack/webpack.config.js
|
365
367
|
- test/test_app/config/webpacker.yml
|
366
368
|
- test/test_app/config/webpacker_manifest_path.yml
|
369
|
+
- test/test_app/config/webpacker_nested_entries.yml
|
367
370
|
- test/test_app/config/webpacker_no_precompile.yml
|
368
371
|
- test/test_app/config/webpacker_other_location.yml
|
369
372
|
- test/test_app/config/webpacker_public_root.yml
|
@@ -1,18 +0,0 @@
|
|
1
|
-
namespace :webpacker do
|
2
|
-
desc "Support for older Rails versions. Install all JavaScript dependencies as specified via Yarn"
|
3
|
-
task :yarn_install do
|
4
|
-
valid_node_envs = %w[test development production]
|
5
|
-
node_env = ENV.fetch("NODE_ENV") do
|
6
|
-
valid_node_envs.include?(Rails.env) ? Rails.env : "production"
|
7
|
-
end
|
8
|
-
Dir.chdir(Rails.root) do
|
9
|
-
yarn_flags =
|
10
|
-
if `yarn --version`.start_with?("1")
|
11
|
-
"--no-progress --frozen-lockfile"
|
12
|
-
else
|
13
|
-
"--immutable"
|
14
|
-
end
|
15
|
-
system({ "NODE_ENV" => node_env }, "yarn install #{yarn_flags}")
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
data/lib/tasks/yarn.rake
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Duplicate of the yarn tasks still present in Rails until Webpacker <5 have been deprecated
|
4
|
-
|
5
|
-
namespace :yarn do
|
6
|
-
desc "Install all JavaScript dependencies as specified via Yarn"
|
7
|
-
task :install do
|
8
|
-
begin
|
9
|
-
# Install only production deps when for not usual envs.
|
10
|
-
valid_node_envs = %w[test development production]
|
11
|
-
node_env = ENV.fetch("NODE_ENV") do
|
12
|
-
valid_node_envs.include?(Rails.env) ? Rails.env : "production"
|
13
|
-
end
|
14
|
-
|
15
|
-
yarn_flags =
|
16
|
-
if `#{RbConfig.ruby} "#{Rails.root}/bin/yarn" --version`.start_with?("1")
|
17
|
-
"--no-progress --frozen-lockfile"
|
18
|
-
else
|
19
|
-
"--immutable"
|
20
|
-
end
|
21
|
-
|
22
|
-
system(
|
23
|
-
{ "NODE_ENV" => node_env },
|
24
|
-
"#{RbConfig.ruby} \"#{Rails.root}/bin/yarn\" install #{yarn_flags}",
|
25
|
-
exception: true
|
26
|
-
)
|
27
|
-
rescue Errno::ENOENT
|
28
|
-
$stderr.puts "bin/yarn was not found."
|
29
|
-
$stderr.puts "Please run `bundle exec rails app:update:bin` to create it."
|
30
|
-
exit 1
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
# Run Yarn prior to Sprockets assets precompilation, so dependencies are available for use.
|
36
|
-
if Rake::Task.task_defined?("assets:precompile") && File.exist?(Rails.root.join("bin", "yarn"))
|
37
|
-
Rake::Task["assets:precompile"].enhance [ "yarn:install" ]
|
38
|
-
end
|