jetpacker 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (190) hide show
  1. checksums.yaml +4 -4
  2. data/.eslintignore +4 -0
  3. data/.eslintrc.js +14 -0
  4. data/.gitignore +11 -11
  5. data/.node-version +1 -0
  6. data/.rubocop.yml +125 -0
  7. data/.travis.yml +54 -5
  8. data/CHANGELOG.jetpacker.md +7 -0
  9. data/CHANGELOG.md +1000 -0
  10. data/CONTRIBUTING.md +33 -0
  11. data/Gemfile +9 -3
  12. data/Gemfile.lock +157 -21
  13. data/MIT-LICENSE +20 -0
  14. data/README.md +671 -16
  15. data/Rakefile +8 -3
  16. data/docs/assets.md +119 -0
  17. data/docs/cloud9.md +310 -0
  18. data/docs/css.md +253 -0
  19. data/docs/deployment.md +130 -0
  20. data/docs/docker.md +68 -0
  21. data/docs/engines.md +200 -0
  22. data/docs/env.md +65 -0
  23. data/docs/es6.md +72 -0
  24. data/docs/folder-structure.md +66 -0
  25. data/docs/misc.md +23 -0
  26. data/docs/props.md +223 -0
  27. data/docs/testing.md +137 -0
  28. data/docs/troubleshooting.md +156 -0
  29. data/docs/typescript.md +126 -0
  30. data/docs/v4-upgrade.md +142 -0
  31. data/docs/webpack-dev-server.md +92 -0
  32. data/docs/webpack.md +364 -0
  33. data/docs/yarn.md +23 -0
  34. data/gemfiles/Gemfile-rails-edge +12 -0
  35. data/gemfiles/Gemfile-rails.4.2.x +9 -0
  36. data/gemfiles/Gemfile-rails.5.0.x +9 -0
  37. data/gemfiles/Gemfile-rails.5.1.x +9 -0
  38. data/gemfiles/Gemfile-rails.5.2.x +9 -0
  39. data/gemfiles/Gemfile-rails.6.0.x +9 -0
  40. data/jetpacker.gemspec +28 -22
  41. data/lib/install/angular.rb +23 -0
  42. data/lib/install/bin/webpack +18 -0
  43. data/lib/install/bin/webpack-dev-server +18 -0
  44. data/lib/install/binstubs.rb +4 -0
  45. data/lib/install/coffee.rb +25 -0
  46. data/lib/install/config/.browserslistrc +1 -0
  47. data/lib/install/config/babel.config.js +72 -0
  48. data/lib/install/config/postcss.config.js +12 -0
  49. data/lib/install/config/webpack/development.js +5 -0
  50. data/lib/install/config/webpack/environment.js +3 -0
  51. data/lib/install/config/webpack/production.js +5 -0
  52. data/lib/install/config/webpack/test.js +5 -0
  53. data/lib/install/config/webpacker.yml +96 -0
  54. data/lib/install/elm.rb +39 -0
  55. data/lib/install/erb.rb +25 -0
  56. data/lib/install/examples/angular/hello_angular.js +7 -0
  57. data/lib/install/examples/angular/hello_angular/app/app.component.ts +9 -0
  58. data/lib/install/examples/angular/hello_angular/app/app.module.ts +16 -0
  59. data/lib/install/examples/angular/hello_angular/index.ts +8 -0
  60. data/lib/install/examples/angular/hello_angular/polyfills.ts +73 -0
  61. data/lib/install/examples/coffee/hello_coffee.coffee +4 -0
  62. data/lib/install/examples/elm/Main.elm +55 -0
  63. data/lib/install/examples/elm/hello_elm.js +16 -0
  64. data/lib/install/examples/erb/hello_erb.js.erb +6 -0
  65. data/lib/install/examples/react/babel.config.js +87 -0
  66. data/lib/install/examples/react/hello_react.jsx +26 -0
  67. data/lib/install/examples/react/tsconfig.json +20 -0
  68. data/lib/install/examples/stimulus/application.js +1 -0
  69. data/lib/install/examples/stimulus/controllers/hello_controller.js +18 -0
  70. data/lib/install/examples/stimulus/controllers/index.js +9 -0
  71. data/lib/install/examples/svelte/app.svelte +11 -0
  72. data/lib/install/examples/svelte/hello_svelte.js +20 -0
  73. data/lib/install/examples/typescript/hello_typescript.ts +4 -0
  74. data/lib/install/examples/typescript/tsconfig.json +23 -0
  75. data/lib/install/examples/vue/app.vue +22 -0
  76. data/lib/install/examples/vue/hello_vue.js +72 -0
  77. data/lib/install/javascript/packs/application.js +18 -0
  78. data/lib/install/loaders/coffee.js +6 -0
  79. data/lib/install/loaders/elm.js +25 -0
  80. data/lib/install/loaders/erb.js +11 -0
  81. data/lib/install/loaders/svelte.js +9 -0
  82. data/lib/install/loaders/typescript.js +11 -0
  83. data/lib/install/loaders/vue.js +6 -0
  84. data/lib/install/react.rb +18 -0
  85. data/lib/install/stimulus.rb +12 -0
  86. data/lib/install/svelte.rb +29 -0
  87. data/lib/install/template.rb +55 -0
  88. data/lib/install/typescript.rb +46 -0
  89. data/lib/install/vue.rb +49 -0
  90. data/lib/jetpacker/version.rb +2 -1
  91. data/lib/tasks/installers.rake +37 -0
  92. data/lib/tasks/webpacker.rake +28 -0
  93. data/lib/tasks/webpacker/binstubs.rake +11 -0
  94. data/lib/tasks/webpacker/check_binstubs.rake +12 -0
  95. data/lib/tasks/webpacker/check_node.rake +24 -0
  96. data/lib/tasks/webpacker/check_yarn.rake +24 -0
  97. data/lib/tasks/webpacker/clean.rake +21 -0
  98. data/lib/tasks/webpacker/clobber.rake +16 -0
  99. data/lib/tasks/webpacker/compile.rake +43 -0
  100. data/lib/tasks/webpacker/info.rake +20 -0
  101. data/lib/tasks/webpacker/install.rake +13 -0
  102. data/lib/tasks/webpacker/verify_install.rake +13 -0
  103. data/lib/tasks/webpacker/yarn_install.rake +21 -0
  104. data/lib/webpacker.rb +46 -0
  105. data/lib/webpacker/commands.rb +50 -0
  106. data/lib/webpacker/compiler.rb +107 -0
  107. data/lib/webpacker/configuration.rb +113 -0
  108. data/lib/webpacker/dev_server.rb +66 -0
  109. data/lib/webpacker/dev_server_proxy.rb +31 -0
  110. data/lib/webpacker/dev_server_runner.rb +72 -0
  111. data/lib/webpacker/env.rb +39 -0
  112. data/lib/webpacker/helper.rb +176 -0
  113. data/lib/webpacker/instance.rb +37 -0
  114. data/lib/webpacker/manifest.rb +118 -0
  115. data/lib/webpacker/railtie.rb +98 -0
  116. data/lib/webpacker/rake_tasks.rb +6 -0
  117. data/lib/webpacker/runner.rb +22 -0
  118. data/lib/webpacker/version.rb +4 -0
  119. data/lib/webpacker/webpack_runner.rb +32 -0
  120. data/package.json +82 -0
  121. data/package/__tests__/config.js +55 -0
  122. data/package/__tests__/dev_server.js +43 -0
  123. data/package/__tests__/development.js +30 -0
  124. data/package/__tests__/env.js +46 -0
  125. data/package/__tests__/production.js +29 -0
  126. data/package/__tests__/staging.js +29 -0
  127. data/package/__tests__/test.js +26 -0
  128. data/package/config.js +37 -0
  129. data/package/config_types/__tests__/config_list.js +118 -0
  130. data/package/config_types/__tests__/config_object.js +43 -0
  131. data/package/config_types/config_list.js +75 -0
  132. data/package/config_types/config_object.js +55 -0
  133. data/package/config_types/index.js +7 -0
  134. data/package/dev_server.js +20 -0
  135. data/package/env.js +19 -0
  136. data/package/environments/__tests__/base.js +74 -0
  137. data/package/environments/base.js +166 -0
  138. data/package/environments/development.js +51 -0
  139. data/package/environments/production.js +79 -0
  140. data/package/environments/test.js +3 -0
  141. data/package/index.js +24 -0
  142. data/package/rules/babel.js +21 -0
  143. data/package/rules/css.js +3 -0
  144. data/package/rules/file.js +20 -0
  145. data/package/rules/index.js +20 -0
  146. data/package/rules/module.css.js +3 -0
  147. data/package/rules/module.sass.js +8 -0
  148. data/package/rules/node_modules.js +24 -0
  149. data/package/rules/sass.js +8 -0
  150. data/package/utils/__tests__/deep_assign.js +32 -0
  151. data/package/utils/__tests__/deep_merge.js +10 -0
  152. data/package/utils/__tests__/get_style_rule.js +65 -0
  153. data/package/utils/__tests__/objectify.js +9 -0
  154. data/package/utils/deep_assign.js +22 -0
  155. data/package/utils/deep_merge.js +22 -0
  156. data/package/utils/get_style_rule.js +45 -0
  157. data/package/utils/helpers.js +58 -0
  158. data/package/utils/objectify.js +3 -0
  159. data/test/command_test.rb +33 -0
  160. data/test/compiler_test.rb +75 -0
  161. data/test/configuration_test.rb +108 -0
  162. data/test/dev_server_runner_test.rb +51 -0
  163. data/test/dev_server_test.rb +47 -0
  164. data/test/env_test.rb +23 -0
  165. data/test/helper_test.rb +142 -0
  166. data/test/manifest_test.rb +42 -0
  167. data/test/rake_tasks_test.rb +69 -0
  168. data/test/test_app/Rakefile +3 -0
  169. data/test/test_app/app/javascript/packs/application.js +10 -0
  170. data/test/test_app/bin/webpack +14 -0
  171. data/test/test_app/bin/webpack-dev-server +14 -0
  172. data/test/test_app/config.ru +5 -0
  173. data/test/test_app/config/application.rb +12 -0
  174. data/test/test_app/config/environment.rb +4 -0
  175. data/test/test_app/config/webpack/development.js +0 -0
  176. data/test/test_app/config/webpacker.yml +97 -0
  177. data/test/test_app/config/webpacker_public_root.yml +19 -0
  178. data/test/test_app/package.json +13 -0
  179. data/test/test_app/public/packs/manifest.json +31 -0
  180. data/test/test_app/yarn.lock +11 -0
  181. data/test/test_helper.rb +33 -0
  182. data/test/webpack_runner_test.rb +51 -0
  183. data/test/webpacker_test.rb +13 -0
  184. data/yarn.lock +8321 -0
  185. metadata +267 -29
  186. data/.rspec +0 -3
  187. data/LICENSE.txt +0 -21
  188. data/bin/console +0 -14
  189. data/bin/setup +0 -8
  190. data/lib/jetpacker.rb +0 -6
@@ -0,0 +1,33 @@
1
+ ## Setting Up a Development Environment
2
+
3
+ 1. Install [Yarn](https://yarnpkg.com/)
4
+
5
+ 2. Run the following commands to set up the development environment.
6
+ ```
7
+ bundle install
8
+ yarn
9
+ ```
10
+
11
+ ## Making sure your changes pass all tests
12
+ There are a number of automated checks which run on Travis CI when a pull request is created.
13
+ You can run those checks on your own locally to make sure that your changes would not break the CI build.
14
+
15
+ ### 1. Check the code for JavaScript style violations
16
+ ```
17
+ yarn lint
18
+ ```
19
+
20
+ ### 2. Check the code for Ruby style violations
21
+ ```
22
+ bundle exec rubocop
23
+ ```
24
+
25
+ ### 3. Run the JavaScript test suite
26
+ ```
27
+ yarn test
28
+ ```
29
+
30
+ ### 4. Run the Ruby test suite
31
+ ```
32
+ bundle exec rake test
33
+ ```
data/Gemfile CHANGED
@@ -1,6 +1,12 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
-
5
- # Specify your gem's dependencies in jetpacker.gemspec
6
3
  gemspec
4
+
5
+ gem "rails"
6
+ gem "rake", ">= 11.1"
7
+ gem "rack-proxy", require: false
8
+
9
+ group :test do
10
+ gem "minitest", "~> 5.0"
11
+ gem "byebug"
12
+ end
@@ -1,35 +1,171 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jetpacker (0.1.0)
4
+ webpacker (4.2.2)
5
+ activesupport (>= 4.2)
6
+ rack-proxy (>= 0.6.1)
7
+ railties (>= 4.2)
5
8
 
6
9
  GEM
7
10
  remote: https://rubygems.org/
8
11
  specs:
9
- diff-lcs (1.3)
10
- rake (10.5.0)
11
- rspec (3.8.0)
12
- rspec-core (~> 3.8.0)
13
- rspec-expectations (~> 3.8.0)
14
- rspec-mocks (~> 3.8.0)
15
- rspec-core (3.8.0)
16
- rspec-support (~> 3.8.0)
17
- rspec-expectations (3.8.2)
18
- diff-lcs (>= 1.2.0, < 2.0)
19
- rspec-support (~> 3.8.0)
20
- rspec-mocks (3.8.0)
21
- diff-lcs (>= 1.2.0, < 2.0)
22
- rspec-support (~> 3.8.0)
23
- rspec-support (3.8.0)
12
+ actioncable (6.0.1)
13
+ actionpack (= 6.0.1)
14
+ nio4r (~> 2.0)
15
+ websocket-driver (>= 0.6.1)
16
+ actionmailbox (6.0.1)
17
+ actionpack (= 6.0.1)
18
+ activejob (= 6.0.1)
19
+ activerecord (= 6.0.1)
20
+ activestorage (= 6.0.1)
21
+ activesupport (= 6.0.1)
22
+ mail (>= 2.7.1)
23
+ actionmailer (6.0.1)
24
+ actionpack (= 6.0.1)
25
+ actionview (= 6.0.1)
26
+ activejob (= 6.0.1)
27
+ mail (~> 2.5, >= 2.5.4)
28
+ rails-dom-testing (~> 2.0)
29
+ actionpack (6.0.1)
30
+ actionview (= 6.0.1)
31
+ activesupport (= 6.0.1)
32
+ rack (~> 2.0)
33
+ rack-test (>= 0.6.3)
34
+ rails-dom-testing (~> 2.0)
35
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
36
+ actiontext (6.0.1)
37
+ actionpack (= 6.0.1)
38
+ activerecord (= 6.0.1)
39
+ activestorage (= 6.0.1)
40
+ activesupport (= 6.0.1)
41
+ nokogiri (>= 1.8.5)
42
+ actionview (6.0.1)
43
+ activesupport (= 6.0.1)
44
+ builder (~> 3.1)
45
+ erubi (~> 1.4)
46
+ rails-dom-testing (~> 2.0)
47
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
48
+ activejob (6.0.1)
49
+ activesupport (= 6.0.1)
50
+ globalid (>= 0.3.6)
51
+ activemodel (6.0.1)
52
+ activesupport (= 6.0.1)
53
+ activerecord (6.0.1)
54
+ activemodel (= 6.0.1)
55
+ activesupport (= 6.0.1)
56
+ activestorage (6.0.1)
57
+ actionpack (= 6.0.1)
58
+ activejob (= 6.0.1)
59
+ activerecord (= 6.0.1)
60
+ marcel (~> 0.3.1)
61
+ activesupport (6.0.1)
62
+ concurrent-ruby (~> 1.0, >= 1.0.2)
63
+ i18n (>= 0.7, < 2)
64
+ minitest (~> 5.1)
65
+ tzinfo (~> 1.1)
66
+ zeitwerk (~> 2.2)
67
+ ast (2.4.0)
68
+ builder (3.2.3)
69
+ byebug (11.0.1)
70
+ concurrent-ruby (1.1.5)
71
+ crass (1.0.5)
72
+ erubi (1.9.0)
73
+ globalid (0.4.2)
74
+ activesupport (>= 4.2.0)
75
+ i18n (1.7.0)
76
+ concurrent-ruby (~> 1.0)
77
+ jaro_winkler (1.5.4)
78
+ loofah (2.3.1)
79
+ crass (~> 1.0.2)
80
+ nokogiri (>= 1.5.9)
81
+ mail (2.7.1)
82
+ mini_mime (>= 0.1.1)
83
+ marcel (0.3.3)
84
+ mimemagic (~> 0.3.2)
85
+ method_source (0.9.2)
86
+ mimemagic (0.3.3)
87
+ mini_mime (1.0.2)
88
+ mini_portile2 (2.4.0)
89
+ minitest (5.13.0)
90
+ nio4r (2.5.2)
91
+ nokogiri (1.10.5)
92
+ mini_portile2 (~> 2.4.0)
93
+ parallel (1.18.0)
94
+ parser (2.6.5.0)
95
+ ast (~> 2.4.0)
96
+ rack (2.0.8)
97
+ rack-proxy (0.6.5)
98
+ rack
99
+ rack-test (1.1.0)
100
+ rack (>= 1.0, < 3)
101
+ rails (6.0.1)
102
+ actioncable (= 6.0.1)
103
+ actionmailbox (= 6.0.1)
104
+ actionmailer (= 6.0.1)
105
+ actionpack (= 6.0.1)
106
+ actiontext (= 6.0.1)
107
+ actionview (= 6.0.1)
108
+ activejob (= 6.0.1)
109
+ activemodel (= 6.0.1)
110
+ activerecord (= 6.0.1)
111
+ activestorage (= 6.0.1)
112
+ activesupport (= 6.0.1)
113
+ bundler (>= 1.3.0)
114
+ railties (= 6.0.1)
115
+ sprockets-rails (>= 2.0.0)
116
+ rails-dom-testing (2.0.3)
117
+ activesupport (>= 4.2.0)
118
+ nokogiri (>= 1.6)
119
+ rails-html-sanitizer (1.3.0)
120
+ loofah (~> 2.3)
121
+ railties (6.0.1)
122
+ actionpack (= 6.0.1)
123
+ activesupport (= 6.0.1)
124
+ method_source
125
+ rake (>= 0.8.7)
126
+ thor (>= 0.20.3, < 2.0)
127
+ rainbow (3.0.0)
128
+ rake (13.0.0)
129
+ rubocop (0.68.1)
130
+ jaro_winkler (~> 1.5.1)
131
+ parallel (~> 1.10)
132
+ parser (>= 2.5, != 2.5.1.1)
133
+ rainbow (>= 2.2.2, < 4.0)
134
+ ruby-progressbar (~> 1.7)
135
+ unicode-display_width (>= 1.4.0, < 1.6)
136
+ rubocop-performance (1.3.0)
137
+ rubocop (>= 0.68.0)
138
+ ruby-progressbar (1.10.1)
139
+ sprockets (4.0.0)
140
+ concurrent-ruby (~> 1.0)
141
+ rack (> 1, < 3)
142
+ sprockets-rails (3.2.1)
143
+ actionpack (>= 4.0)
144
+ activesupport (>= 4.0)
145
+ sprockets (>= 3.0.0)
146
+ thor (0.20.3)
147
+ thread_safe (0.3.6)
148
+ tzinfo (1.2.5)
149
+ thread_safe (~> 0.1)
150
+ unicode-display_width (1.5.0)
151
+ websocket-driver (0.7.1)
152
+ websocket-extensions (>= 0.1.0)
153
+ websocket-extensions (0.1.4)
154
+ zeitwerk (2.2.1)
24
155
 
25
156
  PLATFORMS
26
157
  ruby
27
158
 
28
159
  DEPENDENCIES
29
- bundler (~> 1.17)
30
- jetpacker!
31
- rake (~> 10.0)
32
- rspec (~> 3.0)
160
+ bundler (>= 1.3.0)
161
+ byebug
162
+ minitest (~> 5.0)
163
+ rack-proxy
164
+ rails
165
+ rake (>= 11.1)
166
+ rubocop (< 0.69)
167
+ rubocop-performance
168
+ webpacker!
33
169
 
34
170
  BUNDLED WITH
35
- 1.17.2
171
+ 1.17.3
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2016-2019 David Heinemeier Hansson, Basecamp
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,39 +1,694 @@
1
1
  # Jetpacker
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/jetpacker`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ [![Gem](https://img.shields.io/gem/v/jetpacker.svg)](https://github.com/tongueroo/jetpacker)
4
+
5
+ This is a fork of [rails/webpacker](https://github.com/rails/webpacker) with hacks to get darn webpacker to work with the [Jets](https://rubyonjets.com/) framework. Credit goes to the original authors of the webpacker gem:
6
+
7
+ * David Heinemeier Hansson
8
+ * Gaurav Tiwari
9
+
10
+ Looking for maintainers to help with asset compiling for jets. webpacker seems to be the current preferred solution for compiling assets. The JavaScript world is a bit all over the place though 😱 Unsure if there is a better approach and will consider them. Feel like this current approach is a bit madness 😂
11
+
12
+ ## Summary of Changes
13
+
14
+ Summarizing the changes because they're impossible to remember 🤦🏻‍♂️
15
+
16
+ * Comment out `require "webpacker/railtie"`
17
+ * Replace `Rails.env` with `Jets.env`
18
+ * Replace `Rails.root` with `Jets.root`
19
+ * Add back `rake_tasks.rb` because the Jets CLI uses it create the webpacker rake tasks
20
+ * add `Jets.version` to info command
21
+ * Fix generators by using `Rails::Generators::AppGenerator` directly instead of `bin/stubs`
22
+ * 2 separate versions: `Jetpacker::VERSION` and `Webpacker::VERSION`
23
+
24
+ Happy Hackin' 😁
25
+ Tung
26
+
27
+ ## Branches and Tags
28
+
29
+ Here's info on the git branch and tags strategy.
30
+
31
+ * master: jetpacker fork with latest changes
32
+ * forkpoint-1: git tag of point at which forked from rails/webpacker and changes were made. For diff: `git diff forkpoint-1..v0.2.0`
33
+ * rails git origin: upstream origin with rails/webpacker origin
34
+
35
+ ## Original README Below
36
+
37
+ [![Build Status](https://travis-ci.org/rails/webpacker.svg?branch=master)](https://travis-ci.org/rails/webpacker)
38
+ [![node.js](https://img.shields.io/badge/node-%3E%3D%208.16.0-brightgreen.svg)](https://nodejs.org/en/)
39
+ [![Gem](https://img.shields.io/gem/v/webpacker.svg)](https://github.com/rails/webpacker)
40
+
41
+
42
+ Webpacker makes it easy to use the JavaScript pre-processor and bundler
43
+ [webpack 4.x.x+](https://webpack.js.org/)
44
+ to manage application-like JavaScript in Rails. It coexists with the asset pipeline,
45
+ as the primary purpose for webpack is app-like JavaScript, not images, CSS, or
46
+ even JavaScript Sprinkles (that all continues to live in app/assets).
47
+
48
+ However, it is possible to use Webpacker for CSS, images and fonts assets as well,
49
+ in which case you may not even need the asset pipeline. This is mostly relevant when exclusively using component-based JavaScript frameworks.
50
+
51
+ **NOTE:** The master branch now hosts the code for v4.x.x. Please refer to [3-x-stable](https://github.com/rails/webpacker/tree/3-x-stable) branch for 3.x documentation. See the [v4-upgrade guide](docs/v4-upgrade.md) for an overview of the changes.
52
+
53
+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
54
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
55
+ ## Table of Contents
56
+
57
+ - [Prerequisites](#prerequisites)
58
+ - [Features](#features)
59
+ - [Installation](#installation)
60
+ - [Usage](#usage)
61
+ - [Development](#development)
62
+ - [Webpack Configuration](#webpack-configuration)
63
+ - [Custom Rails environments](#custom-rails-environments)
64
+ - [Upgrading](#upgrading)
65
+ - [Yarn Integrity](#yarn-integrity)
66
+ - [Integrations](#integrations)
67
+ - [React](#react)
68
+ - [Angular with TypeScript](#angular-with-typescript)
69
+ - [Vue](#vue)
70
+ - [Elm](#elm)
71
+ - [Stimulus](#stimulus)
72
+ - [Svelte](#svelte)
73
+ - [CoffeeScript](#coffeescript)
74
+ - [Erb](#erb)
75
+ - [Paths](#paths)
76
+ - [Resolved](#resolved)
77
+ - [Watched](#watched)
78
+ - [Deployment](#deployment)
79
+ - [Docs](#docs)
80
+ - [Contributing](#contributing)
81
+ - [License](#license)
82
+
83
+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
84
+
85
+
86
+ ## Prerequisites
87
+
88
+ * Ruby 2.2+
89
+ * Rails 4.2+
90
+ * Node.js 8.16.0+
91
+ * Yarn 1.x+
92
+
93
+
94
+ ## Features
95
+
96
+ * [webpack 4.x.x](https://webpack.js.org/)
97
+ * ES6 with [babel](https://babeljs.io/)
98
+ * Automatic code splitting using multiple entry points
99
+ * Stylesheets - Sass and CSS
100
+ * Images and fonts
101
+ * PostCSS - Auto-Prefixer
102
+ * Asset compression, source-maps, and minification
103
+ * CDN support
104
+ * React, Angular, Elm and Vue support out-of-the-box
105
+ * Rails view helpers
106
+ * Extensible and configurable
4
107
 
5
- TODO: Delete this and the text above, and describe your gem
6
108
 
7
109
  ## Installation
8
110
 
9
- Add this line to your application's Gemfile:
111
+ You can either add Webpacker during setup of a new Rails 5.1+ application
112
+ using new `--webpack` option:
113
+
114
+ ```bash
115
+ # Available Rails 5.1+
116
+ rails new myapp --webpack
117
+ ```
118
+
119
+ Or add it to your `Gemfile`:
120
+
121
+ ```ruby
122
+ # Gemfile
123
+ gem 'webpacker', '~> 4.x'
124
+
125
+ # OR if you prefer to use master
126
+ gem 'webpacker', git: 'https://github.com/rails/webpacker.git'
127
+ yarn add https://github.com/rails/webpacker.git
128
+ yarn add core-js regenerator-runtime
129
+ ```
130
+
131
+ Finally, run the following to install Webpacker:
132
+
133
+ ```bash
134
+ bundle
135
+ bundle exec rails webpacker:install
136
+
137
+ # OR (on rails version < 5.0)
138
+ bundle exec rake webpacker:install
139
+ ```
140
+
141
+ Optional: To fix ["unmet peer dependency" warnings](https://github.com/rails/webpacker/issues/1078),
142
+
143
+ ```bash
144
+ yarn upgrade
145
+ ```
146
+
147
+ ### Usage
148
+
149
+ Once installed, you can start writing modern ES6-flavored JavaScript apps right away:
150
+
151
+ ```yml
152
+ app/javascript:
153
+ ├── packs:
154
+ │ # only webpack entry files here
155
+ │ └── application.js
156
+ └── src:
157
+ │ └── application.css
158
+ └── images:
159
+ └── logo.svg
160
+ ```
161
+
162
+ In `/packs/application.js`, include this at the top of the file:
163
+
164
+ ```js
165
+ import "core-js/stable";
166
+ import "regenerator-runtime/runtime";
167
+ ```
168
+
169
+ You can then link the JavaScript pack in Rails views using the `javascript_pack_tag` helper.
170
+ If you have styles imported in your pack file, you can link them by using `stylesheet_pack_tag`:
171
+
172
+ ```erb
173
+ <%= javascript_pack_tag 'application' %>
174
+ <%= stylesheet_pack_tag 'application' %>
175
+ ```
176
+
177
+ If you want to link a static asset for `<link rel="prefetch">` or `<img />` tag, you
178
+ can use the `asset_pack_path` helper:
179
+
180
+ ```erb
181
+ <link rel="prefetch" href="<%= asset_pack_path 'application.css' %>" />
182
+ <img src="<%= asset_pack_path 'images/logo.svg' %>" />
183
+ ```
184
+
185
+ If you are using new webpack 4 split chunks API, then consider using `javascript_packs_with_chunks_tag` helper, which creates html
186
+ tags for a pack and all the dependent chunks.
187
+
188
+ ```erb
189
+ <%= javascript_packs_with_chunks_tag 'calendar', 'map', 'data-turbolinks-track': 'reload' %>
190
+
191
+ <script src="/packs/vendor-16838bab065ae1e314.js" data-turbolinks-track="reload"></script>
192
+ <script src="/packs/calendar~runtime-16838bab065ae1e314.js" data-turbolinks-track="reload"></script>
193
+ <script src="/packs/calendar-1016838bab065ae1e314.js" data-turbolinks-track="reload"></script>
194
+ <script src="/packs/map~runtime-16838bab065ae1e314.js" data-turbolinks-track="reload"></script>
195
+ <script src="/packs/map-16838bab065ae1e314.js" data-turbolinks-track="reload"></script>
196
+ ```
197
+
198
+ **Important:** Pass all your pack names when using `javascript_packs_with_chunks_tag`
199
+ helper otherwise you will get duplicated chunks on the page.
200
+
201
+ ```erb
202
+ <%# DO %>
203
+ <%= javascript_packs_with_chunks_tag 'calendar', 'map' %>
204
+
205
+ <%# DON'T %>
206
+ <%= javascript_packs_with_chunks_tag 'calendar' %>
207
+ <%= javascript_packs_with_chunks_tag 'map' %>
208
+ ```
209
+
210
+ **Note:** In order for your styles or static assets files to be available in your view,
211
+ you would need to link them in your "pack" or entry file.
212
+
213
+
214
+ ### Development
215
+
216
+ Webpacker ships with two binstubs: `./bin/webpack` and `./bin/webpack-dev-server`.
217
+ Both are thin wrappers around the standard `webpack.js` and `webpack-dev-server.js`
218
+ executables to ensure that the right configuration files and environmental variables
219
+ are loaded based on your environment.
220
+
221
+ In development, Webpacker compiles on demand rather than upfront by default. This
222
+ happens when you refer to any of the pack assets using the Webpacker helper methods.
223
+ This means that you don't have to run any separate processes. Compilation errors are logged
224
+ to the standard Rails log.
225
+
226
+ 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/webpack-dev-server` or `ruby ./bin/webpack-dev-server`. Windows users will need to run these commands
227
+ in a terminal separate from `bundle exec rails s`. This process will watch for changes
228
+ in the `app/javascript/packs/*.js` files and automatically reload the browser to match.
229
+
230
+ ```bash
231
+ # webpack dev server
232
+ ./bin/webpack-dev-server
233
+
234
+ # watcher
235
+ ./bin/webpack --watch --colors --progress
236
+
237
+ # standalone build
238
+ ./bin/webpack
239
+ ```
240
+
241
+ Once you start this development server, Webpacker will automatically start proxying all
242
+ webpack asset requests to this server. When you stop the server, it'll revert back to
243
+ on-demand compilation.
244
+
245
+ You can use environment variables as options supported by
246
+ [webpack-dev-server](https://webpack.js.org/configuration/dev-server/) in the
247
+ form `WEBPACKER_DEV_SERVER_<OPTION>`. Please note that these environmental
248
+ variables will always take precedence over the ones already set in the
249
+ configuration file, and that the _same_ environmental variables must
250
+ be available to the `rails server` process.
251
+
252
+ ```bash
253
+ WEBPACKER_DEV_SERVER_HOST=example.com WEBPACKER_DEV_SERVER_INLINE=true WEBPACKER_DEV_SERVER_HOT=false ./bin/webpack-dev-server
254
+ ```
255
+
256
+ By default, the webpack dev server listens on `localhost` in development for security purposes.
257
+ However, if you want your app to be available over local LAN IP or a VM instance like vagrant,
258
+ you can set the `host` when running `./bin/webpack-dev-server` binstub:
259
+
260
+ ```bash
261
+ WEBPACKER_DEV_SERVER_HOST=0.0.0.0 ./bin/webpack-dev-server
262
+ ```
263
+
264
+ **Note:** You need to allow webpack-dev-server host as an allowed origin for `connect-src` if you are running your application in a restrict CSP environment (like Rails 5.2+). This can be done in Rails 5.2+ in the CSP initializer `config/initializers/content_security_policy.rb` with a snippet like this:
265
+
266
+ ```ruby
267
+ Rails.application.config.content_security_policy do |policy|
268
+ policy.connect_src :self, :https, 'http://localhost:3035', 'ws://localhost:3035' if Rails.env.development?
269
+ end
270
+ ```
271
+
272
+ **Note:** Don't forget to prefix `ruby` when running these binstubs on Windows
273
+
274
+ ### Webpack Configuration
275
+
276
+ See [docs/webpack](docs/webpack.md) for modifying webpack configuration and loaders.
277
+
278
+
279
+ ### Custom Rails environments
280
+
281
+ Out of the box Webpacker 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. Webpacker supports this out of the box from version 3.4.0+ onwards.
282
+
283
+ You can choose to define additional environment configurations in webpacker.yml,
284
+
285
+ ```yml
286
+ staging:
287
+ <<: *default
288
+
289
+ # Production depends on precompilation of packs prior to booting for performance.
290
+ compile: false
291
+
292
+ # Cache manifest.json for performance
293
+ cache_manifest: true
294
+
295
+ # Compile staging packs to a separate directory
296
+ public_output_path: packs-staging
297
+ ```
298
+
299
+ or, Webpacker will use production environment as a fallback environment for loading configurations. Please note, `NODE_ENV` can either be set to `production`, `development` or `test`.
300
+ 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`.
301
+
302
+ 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:
303
+
304
+ ```bash
305
+ RAILS_ENV=staging bundle exec rails assets:precompile
306
+ ```
307
+
308
+ And, this will compile in development mode and load configuration for cucumber environment
309
+ if defined in webpacker.yml or fallback to production configuration
310
+
311
+ ```bash
312
+ RAILS_ENV=cucumber NODE_ENV=development bundle exec rails assets:precompile
313
+ ```
314
+
315
+ Please note, binstubs compiles in development mode however rake tasks
316
+ compiles in production mode.
317
+
318
+ ```bash
319
+ # Compiles in development mode unless NODE_ENV is specified
320
+ ./bin/webpack
321
+ ./bin/webpack-dev-server
322
+
323
+ # compiles in production mode by default unless NODE_ENV is specified
324
+ bundle exec rails assets:precompile
325
+ bundle exec rails webpacker:compile
326
+ ```
327
+
328
+
329
+ ### Upgrading
330
+
331
+ You can run following commands to upgrade Webpacker to the latest stable version. This process involves upgrading the gem and related JavaScript packages:
332
+
333
+ ```bash
334
+ bundle update webpacker
335
+ rails webpacker:binstubs
336
+ yarn upgrade @rails/webpacker --latest
337
+ yarn upgrade webpack-dev-server --latest
338
+
339
+ # Or to install the latest release (including pre-releases)
340
+ yarn add @rails/webpacker@next
341
+ ```
342
+
343
+ ### Yarn Integrity
344
+
345
+ By default, in development, webpacker runs a yarn integrity check to ensure that all local JavaScript packages are up-to-date. This is similar to what bundler does currently in Rails, but for JavaScript packages. If your system is out of date, then Rails will not initialize. You will be asked to upgrade your local JavaScript packages by running `yarn install`.
346
+
347
+ To turn off this option, you will need to change the default setting in `config/webpacker.yml`:
348
+
349
+ ```yaml
350
+ # config/webpacker.yml
351
+ development:
352
+ ...
353
+ # Verifies that correct packages and versions are installed by inspecting package.json, yarn.lock, and node_modules
354
+ check_yarn_integrity: false
355
+ ```
356
+
357
+ You may also turn on this feature by adding the config option for any Rails environment in `config/webpacker.yml`:
358
+
359
+ ```yaml
360
+ check_yarn_integrity: true
361
+ ```
362
+
363
+ ## Integrations
364
+
365
+ Webpacker ships with basic out-of-the-box integration for React, Angular, Vue and Elm.
366
+ You can see a list of available commands/tasks by running `bundle exec rails webpacker`:
367
+
368
+ ### React
369
+
370
+ To use Webpacker with [React](https://facebook.github.io/react/), create a
371
+ new Rails 5.1+ app using `--webpack=react` option:
372
+
373
+ ```bash
374
+ # Rails 5.1+
375
+ rails new myapp --webpack=react
376
+ ```
377
+
378
+ (or run `bundle exec rails webpacker:install:react` in an existing Rails app already
379
+ setup with Webpacker).
380
+
381
+ The installer will add all relevant dependencies using Yarn, changes
382
+ to the configuration files, and an example React component to your
383
+ project in `app/javascript/packs` so that you can experiment with React right away.
384
+
385
+
386
+ ### Angular with TypeScript
387
+
388
+ To use Webpacker with [Angular](https://angular.io/), create a
389
+ new Rails 5.1+ app using `--webpack=angular` option:
390
+
391
+ ```bash
392
+ # Rails 5.1+
393
+ rails new myapp --webpack=angular
394
+ ```
395
+
396
+ (or run `bundle exec rails webpacker:install:angular` on a Rails app already
397
+ setup with Webpacker).
398
+
399
+ The installer will add the TypeScript and Angular core libraries using Yarn alongside
400
+ a few changes to the configuration files. An example component written in
401
+ TypeScript will also be added to your project in `app/javascript` so that
402
+ you can experiment with Angular right away.
403
+
404
+ By default, Angular uses a JIT compiler for development environment. This
405
+ compiler is not compatible with restrictive CSP (Content Security
406
+ Policy) environments like Rails 5.2+. You can use Angular AOT compiler
407
+ in development with the [@ngtools/webpack](https://www.npmjs.com/package/@ngtools/webpack#usage) plugin.
408
+
409
+ Alternatively if you're using Rails 5.2+ you can enable `unsafe-eval` rule for your
410
+ development environment. This can be done in the `config/initializers/content_security_policy.rb`
411
+ with the following code:
10
412
 
11
413
  ```ruby
12
- gem 'jetpacker'
414
+ Rails.application.config.content_security_policy do |policy|
415
+ if Rails.env.development?
416
+ policy.script_src :self, :https, :unsafe_eval
417
+ else
418
+ policy.script_src :self, :https
419
+ end
420
+ end
13
421
  ```
14
422
 
15
- And then execute:
16
423
 
17
- $ bundle
424
+ ### Vue
18
425
 
19
- Or install it yourself as:
426
+ To use Webpacker with [Vue](https://vuejs.org/), create a
427
+ new Rails 5.1+ app using `--webpack=vue` option:
20
428
 
21
- $ gem install jetpacker
429
+ ```bash
430
+ # Rails 5.1+
431
+ rails new myapp --webpack=vue
432
+ ```
433
+ (or run `bundle exec rails webpacker:install:vue` on a Rails app already setup with Webpacker).
22
434
 
23
- ## Usage
435
+ The installer will add Vue and its required libraries using Yarn alongside
436
+ automatically applying changes needed to the configuration files. An example component will
437
+ be added to your project in `app/javascript` so that you can experiment with Vue right away.
24
438
 
25
- TODO: Write usage instructions here
439
+ If you're using Rails 5.2+ you'll need to enable `unsafe-eval` rule for your development environment.
440
+ This can be done in the `config/initializers/content_security_policy.rb` with the following
441
+ configuration:
26
442
 
27
- ## Development
443
+ ```ruby
444
+ Rails.application.config.content_security_policy do |policy|
445
+ if Rails.env.development?
446
+ policy.script_src :self, :https, :unsafe_eval
447
+ else
448
+ policy.script_src :self, :https
449
+ end
450
+ end
451
+ ```
452
+ You can read more about this in the [Vue docs](https://vuejs.org/v2/guide/installation.html#CSP-environments).
453
+
454
+ #### Lazy loading integration
455
+
456
+ See [docs/es6](docs/es6.md) to know more about Webpack and Webpacker configuration.
457
+
458
+ For instance, you can lazy load Vue JS components:
459
+
460
+ Before:
461
+ ```js
462
+ import Vue from 'vue'
463
+ import { VCard } from 'vuetify/lib'
464
+
465
+ Vue.component('VCard', VCard)
466
+ ```
467
+
468
+ After:
469
+ ```js
470
+ import Vue from 'vue'
471
+
472
+ // With destructuring assignment
473
+ Vue.component('VCard', import('vuetify/lib').then(({ VCard }) => VCard)
474
+
475
+ // Or without destructuring assignment
476
+ Vue.component('OtherComponent', () => import('./OtherComponent'))
477
+ ```
478
+
479
+ You can use it in a Single File Component as well:
480
+
481
+ ```html
482
+ <template>
483
+ ...
484
+ </template>
485
+
486
+ <script>
487
+ export default {
488
+ components: {
489
+ OtherComponent: () => import('./OtherComponent')
490
+ }
491
+ }
492
+ </script>
493
+ ```
494
+
495
+ By wrapping the import function into an arrow function, Vue will execute it only when it gets requested, loading the module in that moment.
496
+
497
+ ##### Automatic registration
498
+
499
+ ```js
500
+ /**
501
+ * The following block of code may be used to automatically register your
502
+ * Vue components. It will recursively scan this directory for the Vue
503
+ * components and automatically register them with their "basename".
504
+ *
505
+ * Eg. ./components/OtherComponent.vue -> <other-component></other-component>
506
+ * Eg. ./UI/ButtonComponent.vue -> <button-component></button-component>
507
+ */
508
+
509
+ const files = require.context('./', true, /\.vue$/i)
510
+ files.keys().map(key => {
511
+ const component = key.split('/').pop().split('.')[0]
512
+
513
+ // With Lazy Loading
514
+ Vue.component(component, () => import(`${key}`))
515
+
516
+ // Or without Lazy Loading
517
+ Vue.component(component, files(key).default)
518
+ })
519
+ ```
520
+
521
+ ### Elm
522
+
523
+ To use Webpacker with [Elm](http://elm-lang.org), create a
524
+ new Rails 5.1+ app using `--webpack=elm` option:
525
+
526
+ ```
527
+ # Rails 5.1+
528
+ rails new myapp --webpack=elm
529
+ ```
28
530
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
531
+ (or run `bundle exec rails webpacker:install:elm` on a Rails app already setup with Webpacker).
532
+
533
+ The Elm library and its core packages will be added via Yarn and Elm.
534
+ An example `Main.elm` app will also be added to your project in `app/javascript`
535
+ so that you can experiment with Elm right away.
536
+
537
+ ### Svelte
538
+
539
+ To use Webpacker with [Svelte](https://svelte.dev), create a
540
+ new Rails 5.1+ app using `--webpack=svelte` option:
541
+
542
+ ```
543
+ # Rails 5.1+
544
+ rails new myapp --webpack=svelte
545
+ ```
546
+
547
+ (or run `bundle exec rails webpacker:install:svelte` on a Rails app already setup with Webpacker).
548
+
549
+ Please play with the [Svelte Tutorial](https://svelte.dev/tutorial/basics) or learn more about its API at https://svelte.dev/docs
550
+
551
+ ### Stimulus
552
+
553
+ To use Webpacker with [Stimulus](http://stimulusjs.org), create a
554
+ new Rails 5.1+ app using `--webpack=stimulus` option:
555
+
556
+ ```
557
+ # Rails 5.1+
558
+ rails new myapp --webpack=stimulus
559
+ ```
560
+
561
+ (or run `bundle exec rails webpacker:install:stimulus` on a Rails app already setup with Webpacker).
562
+
563
+ Please read [The Stimulus Handbook](https://stimulusjs.org/handbook/introduction) or learn more about its source code at https://github.com/stimulusjs/stimulus
564
+
565
+ ### CoffeeScript
566
+
567
+ To add [CoffeeScript](http://coffeescript.org/) support,
568
+ run `bundle exec rails webpacker:install:coffee` on a Rails app already
569
+ setup with Webpacker.
570
+
571
+ An example `hello_coffee.coffee` file will also be added to your project
572
+ in `app/javascript/packs` so that you can experiment with CoffeeScript right away.
573
+
574
+ ### Erb
575
+
576
+ To add [Erb](https://apidock.com/ruby/ERB) support in your JS templates,
577
+ run `bundle exec rails webpacker:install:erb` on a Rails app already
578
+ setup with Webpacker.
579
+
580
+ An example `hello_erb.js.erb` file will also be added to your project
581
+ in `app/javascript/packs` so that you can experiment with Erb-flavoured
582
+ javascript right away.
583
+
584
+
585
+ ## Paths
586
+
587
+ By default, Webpacker ships with simple conventions for where the JavaScript
588
+ app files and compiled webpack bundles will go in your Rails app.
589
+ All these options are configurable from `config/webpacker.yml` file.
590
+
591
+ The configuration for what webpack is supposed to compile by default rests
592
+ on the convention that every file in `app/javascript/packs/*`**(default)**
593
+ or whatever path you set for `source_entry_path` in the `webpacker.yml` configuration
594
+ is turned into their own output files (or entry points, as webpack calls it). Therefore you don't want to put anything inside `packs` directory that you do not want to be
595
+ an entry file. As a rule of thumb, put all files you want to link in your views inside
596
+ "packs" directory and keep everything else under `app/javascript`.
597
+
598
+ Suppose you want to change the source directory from `app/javascript`
599
+ to `frontend` and output to `assets/packs`. This is how you would do it:
600
+
601
+ ```yml
602
+ # config/webpacker.yml
603
+ source_path: frontend
604
+ source_entry_path: packs
605
+ public_output_path: assets/packs # outputs to => public/assets/packs
606
+ ```
607
+
608
+ Similarly you can also control and configure `webpack-dev-server` settings from `config/webpacker.yml` file:
609
+
610
+ ```yml
611
+ # config/webpacker.yml
612
+ development:
613
+ dev_server:
614
+ host: localhost
615
+ port: 3035
616
+ ```
617
+
618
+ If you have `hmr` turned to true, then the `stylesheet_pack_tag` generates no output, as you will want to configure your styles to be inlined in your JavaScript for hot reloading. During production and testing, the `stylesheet_pack_tag` will create the appropriate HTML tags.
619
+
620
+
621
+ ### Resolved
622
+
623
+ If you are adding Webpacker to an existing app that has most of the assets inside
624
+ `app/assets` or inside an engine, and you want to share that
625
+ with webpack modules, you can use the `resolved_paths`
626
+ option available in `config/webpacker.yml`. This lets you
627
+ add additional paths that webpack should lookup when resolving modules:
628
+
629
+ ```yml
630
+ resolved_paths: ['app/assets']
631
+ ```
632
+
633
+ You can then import these items inside your modules like so:
634
+
635
+ ```js
636
+ // Note it's relative to parent directory i.e. app/assets
637
+ import 'stylesheets/main'
638
+ import 'images/rails.png'
639
+ ```
640
+
641
+ **Note:** Please be careful when adding paths here otherwise it
642
+ will make the compilation slow, consider adding specific paths instead of
643
+ whole parent directory if you just need to reference one or two modules
644
+
645
+
646
+ ### Watched
647
+
648
+ By default, the lazy compilation is cached until a file is changed under your
649
+ tracked paths. You can configure which paths are tracked
650
+ by adding new paths to `watched_paths` array. This is much like Rails' `autoload_paths`:
651
+
652
+ ```rb
653
+ # config/initializers/webpacker.rb
654
+ # or config/application.rb
655
+ Webpacker::Compiler.watched_paths << 'bower_components'
656
+ ```
657
+
658
+
659
+ ## Deployment
660
+
661
+ Webpacker 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).
662
+
663
+
664
+ ## Docs
665
+
666
+ - [Development](https://github.com/rails/webpacker#development)
667
+ - [Webpack](./docs/webpack.md)
668
+ - [Webpack-dev-server](./docs/webpack-dev-server.md)
669
+ - [Environment Variables](./docs/env.md)
670
+ - [Folder Structure](./docs/folder-structure.md)
671
+ - [Assets](./docs/assets.md)
672
+ - [CSS, Sass and SCSS](./docs/css.md)
673
+ - [ES6](./docs/es6.md)
674
+ - [Props](./docs/props.md)
675
+ - [Typescript](./docs/typescript.md)
676
+ - [Yarn](./docs/yarn.md)
677
+ - [Misc](./docs/misc.md)
678
+ - [Deployment](./docs/deployment.md)
679
+ - [Docker](./docs/docker.md)
680
+ - [Using in Rails engines](./docs/engines.md)
681
+ - [Webpacker on Cloud9](./docs/cloud9.md)
682
+ - [Testing](./docs/testing.md)
683
+ - [Troubleshooting](./docs/troubleshooting.md)
684
+ - [v3 to v4 Upgrade Guide](./docs/v4-upgrade.md)
30
685
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
686
 
33
687
  ## Contributing
688
+ [![Code Helpers](https://www.codetriage.com/rails/webpacker/badges/users.svg)](https://www.codetriage.com/rails/webpacker)
34
689
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/jetpacker.
690
+ We encourage you to contribute to Webpacker! See [CONTRIBUTING](CONTRIBUTING.md) for guidelines about how to proceed.
36
691
 
37
- ## License
38
692
 
39
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
693
+ ## License
694
+ Webpacker is released under the [MIT License](https://opensource.org/licenses/MIT).