webpacker 5.0.1 → 6.0.0.beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (172) hide show
  1. checksums.yaml +4 -4
  2. data/.eslintrc.js +8 -8
  3. data/.github/workflows/jest.yml +38 -0
  4. data/.github/workflows/js-lint.yml +39 -0
  5. data/.github/workflows/rubocop.yml +39 -0
  6. data/.github/workflows/ruby.yml +70 -0
  7. data/.gitignore +2 -0
  8. data/.node-version +1 -1
  9. data/.rubocop.yml +11 -16
  10. data/6_0_upgrade.md +43 -0
  11. data/CHANGELOG.md +49 -3
  12. data/CONTRIBUTING.md +1 -1
  13. data/Gemfile.lock +91 -85
  14. data/README.md +233 -133
  15. data/lib/install/config/webpack/base.js +3 -0
  16. data/lib/install/config/webpack/development.js +2 -2
  17. data/lib/install/config/webpack/production.js +2 -2
  18. data/lib/install/config/webpack/test.js +2 -2
  19. data/lib/install/config/webpacker.yml +9 -42
  20. data/lib/install/javascript/packs/application.css +9 -0
  21. data/lib/install/javascript/packs/application.js +3 -1
  22. data/lib/install/template.rb +33 -19
  23. data/lib/tasks/webpacker.rake +2 -11
  24. data/lib/tasks/webpacker/binstubs.rake +6 -4
  25. data/lib/tasks/webpacker/check_binstubs.rake +4 -4
  26. data/lib/tasks/webpacker/check_node.rake +1 -1
  27. data/lib/tasks/webpacker/check_yarn.rake +2 -3
  28. data/lib/tasks/webpacker/compile.rake +4 -2
  29. data/lib/tasks/webpacker/info.rake +12 -10
  30. data/lib/tasks/webpacker/install.rake +6 -4
  31. data/lib/tasks/webpacker/verify_install.rake +2 -1
  32. data/lib/tasks/webpacker/yarn_install.rake +9 -1
  33. data/lib/webpacker/commands.rb +1 -1
  34. data/lib/webpacker/compiler.rb +22 -11
  35. data/lib/webpacker/configuration.rb +7 -27
  36. data/lib/webpacker/dev_server_proxy.rb +3 -1
  37. data/lib/webpacker/dev_server_runner.rb +23 -4
  38. data/lib/webpacker/helper.rb +55 -46
  39. data/lib/webpacker/manifest.rb +1 -1
  40. data/lib/webpacker/railtie.rb +0 -43
  41. data/lib/webpacker/runner.rb +1 -0
  42. data/lib/webpacker/version.rb +1 -1
  43. data/lib/webpacker/webpack_runner.rb +7 -2
  44. data/package.json +27 -43
  45. data/package/__tests__/config.js +6 -27
  46. data/package/__tests__/dev_server.js +2 -0
  47. data/package/__tests__/development.js +18 -7
  48. data/package/__tests__/env.js +12 -4
  49. data/package/__tests__/production.js +6 -6
  50. data/package/__tests__/staging.js +7 -6
  51. data/package/__tests__/test.js +4 -5
  52. data/package/babel/preset.js +55 -0
  53. data/package/config.js +4 -9
  54. data/package/configPath.js +3 -0
  55. data/package/dev_server.js +1 -1
  56. data/package/env.js +9 -4
  57. data/package/environments/__tests__/base.js +21 -36
  58. data/package/environments/base.js +63 -127
  59. data/package/environments/development.js +46 -39
  60. data/package/environments/production.js +63 -70
  61. data/package/environments/test.js +2 -2
  62. data/package/index.js +13 -8
  63. data/package/rules/babel.js +20 -11
  64. data/package/rules/coffee.js +6 -0
  65. data/package/rules/erb.js +15 -0
  66. data/package/rules/file.js +19 -18
  67. data/package/rules/index.js +15 -18
  68. data/package/rules/less.js +22 -0
  69. data/package/rules/sass.js +13 -10
  70. data/package/rules/svg.js +20 -0
  71. data/package/utils/get_style_rule.js +26 -36
  72. data/package/utils/helpers.js +26 -35
  73. data/test/compiler_test.rb +4 -11
  74. data/test/configuration_test.rb +2 -32
  75. data/test/dev_server_runner_test.rb +25 -6
  76. data/test/engine_rake_tasks_test.rb +39 -0
  77. data/test/helper_test.rb +18 -9
  78. data/test/mounted_app/Rakefile +4 -0
  79. data/test/mounted_app/test/dummy/Rakefile +3 -0
  80. data/test/mounted_app/test/dummy/bin/rails +3 -0
  81. data/test/mounted_app/test/dummy/bin/rake +3 -0
  82. data/test/mounted_app/test/dummy/config.ru +5 -0
  83. data/test/mounted_app/test/dummy/config/application.rb +10 -0
  84. data/test/mounted_app/test/dummy/config/environment.rb +3 -0
  85. data/test/mounted_app/test/dummy/config/webpacker.yml +75 -0
  86. data/test/mounted_app/test/dummy/package.json +7 -0
  87. data/test/rake_tasks_test.rb +1 -10
  88. data/test/test_app/config/application.rb +0 -1
  89. data/test/test_app/config/webpacker.yml +3 -21
  90. data/test/test_app/config/webpacker_public_root.yml +0 -1
  91. data/test/test_app/public/packs/manifest.json +18 -13
  92. data/test/test_app/some.config.js +0 -0
  93. data/test/webpack_runner_test.rb +10 -4
  94. data/webpacker.gemspec +1 -1
  95. data/yarn.lock +2657 -6224
  96. metadata +49 -90
  97. data/.travis.yml +0 -43
  98. data/docs/assets.md +0 -119
  99. data/docs/cloud9.md +0 -310
  100. data/docs/css.md +0 -253
  101. data/docs/deployment.md +0 -130
  102. data/docs/docker.md +0 -68
  103. data/docs/engines.md +0 -213
  104. data/docs/env.md +0 -65
  105. data/docs/es6.md +0 -72
  106. data/docs/folder-structure.md +0 -66
  107. data/docs/integrations.md +0 -220
  108. data/docs/misc.md +0 -23
  109. data/docs/props.md +0 -223
  110. data/docs/testing.md +0 -137
  111. data/docs/troubleshooting.md +0 -156
  112. data/docs/typescript.md +0 -125
  113. data/docs/v4-upgrade.md +0 -142
  114. data/docs/webpack-dev-server.md +0 -92
  115. data/docs/webpack.md +0 -364
  116. data/docs/yarn.md +0 -23
  117. data/lib/install/angular.rb +0 -23
  118. data/lib/install/coffee.rb +0 -25
  119. data/lib/install/config/.browserslistrc +0 -1
  120. data/lib/install/config/babel.config.js +0 -72
  121. data/lib/install/config/postcss.config.js +0 -12
  122. data/lib/install/config/webpack/environment.js +0 -3
  123. data/lib/install/elm.rb +0 -39
  124. data/lib/install/erb.rb +0 -25
  125. data/lib/install/examples/angular/hello_angular.js +0 -7
  126. data/lib/install/examples/angular/hello_angular/app/app.component.ts +0 -9
  127. data/lib/install/examples/angular/hello_angular/app/app.module.ts +0 -16
  128. data/lib/install/examples/angular/hello_angular/index.ts +0 -8
  129. data/lib/install/examples/angular/hello_angular/polyfills.ts +0 -73
  130. data/lib/install/examples/coffee/hello_coffee.coffee +0 -4
  131. data/lib/install/examples/elm/Main.elm +0 -55
  132. data/lib/install/examples/elm/hello_elm.js +0 -16
  133. data/lib/install/examples/erb/hello_erb.js.erb +0 -6
  134. data/lib/install/examples/react/babel.config.js +0 -87
  135. data/lib/install/examples/react/hello_react.jsx +0 -26
  136. data/lib/install/examples/react/tsconfig.json +0 -20
  137. data/lib/install/examples/stimulus/application.js +0 -1
  138. data/lib/install/examples/stimulus/controllers/hello_controller.js +0 -18
  139. data/lib/install/examples/stimulus/controllers/index.js +0 -9
  140. data/lib/install/examples/svelte/app.svelte +0 -11
  141. data/lib/install/examples/svelte/hello_svelte.js +0 -20
  142. data/lib/install/examples/typescript/hello_typescript.ts +0 -4
  143. data/lib/install/examples/typescript/tsconfig.json +0 -23
  144. data/lib/install/examples/vue/app.vue +0 -22
  145. data/lib/install/examples/vue/hello_vue.js +0 -72
  146. data/lib/install/loaders/coffee.js +0 -6
  147. data/lib/install/loaders/elm.js +0 -25
  148. data/lib/install/loaders/erb.js +0 -11
  149. data/lib/install/loaders/svelte.js +0 -9
  150. data/lib/install/loaders/typescript.js +0 -11
  151. data/lib/install/loaders/vue.js +0 -6
  152. data/lib/install/react.rb +0 -18
  153. data/lib/install/stimulus.rb +0 -12
  154. data/lib/install/svelte.rb +0 -29
  155. data/lib/install/typescript.rb +0 -46
  156. data/lib/install/vue.rb +0 -49
  157. data/lib/tasks/installers.rake +0 -42
  158. data/package/config_types/__tests__/config_list.js +0 -118
  159. data/package/config_types/__tests__/config_object.js +0 -43
  160. data/package/config_types/config_list.js +0 -75
  161. data/package/config_types/config_object.js +0 -55
  162. data/package/config_types/index.js +0 -7
  163. data/package/rules/module.css.js +0 -3
  164. data/package/rules/module.sass.js +0 -8
  165. data/package/rules/node_modules.js +0 -24
  166. data/package/utils/__tests__/deep_assign.js +0 -32
  167. data/package/utils/__tests__/deep_merge.js +0 -10
  168. data/package/utils/__tests__/get_style_rule.js +0 -65
  169. data/package/utils/__tests__/objectify.js +0 -9
  170. data/package/utils/deep_assign.js +0 -22
  171. data/package/utils/deep_merge.js +0 -22
  172. data/package/utils/objectify.js +0 -3
data/README.md CHANGED
@@ -1,11 +1,15 @@
1
1
  # Webpacker
2
2
 
3
- [![Build Status](https://travis-ci.org/rails/webpacker.svg?branch=master)](https://travis-ci.org/rails/webpacker)
4
- [![node.js](https://img.shields.io/badge/node-%3E%3D%2010.13.0-brightgreen.svg)](https://www.npmjs.com/package/@rails/webpacker)
3
+ [![Ruby specs](https://github.com/rails/webpacker/workflows/Ruby%20specs/badge.svg)](https://github.com/rails/webpacker/actions)
4
+ [![Jest specs](https://github.com/rails/webpacker/workflows/Jest%20specs/badge.svg)](https://github.com/rails/webpacker/actions)
5
+ [![Rubocop](https://github.com/rails/webpacker/workflows/Rubocop/badge.svg)](https://github.com/rails/webpacker/actions)
6
+ [![JS lint](https://github.com/rails/webpacker/workflows/JS%20lint/badge.svg)](https://github.com/rails/webpacker/actions)
7
+
8
+ [![node.js](https://img.shields.io/badge/node-%3E%3D%2010.17.0-brightgreen.svg)](https://www.npmjs.com/package/@rails/webpacker)
5
9
  [![Gem](https://img.shields.io/gem/v/webpacker.svg)](https://rubygems.org/gems/webpacker)
6
10
 
7
11
  Webpacker makes it easy to use the JavaScript pre-processor and bundler
8
- [webpack 4.x.x+](https://webpack.js.org/)
12
+ [webpack 5.x.x+](https://webpack.js.org/)
9
13
  to manage application-like JavaScript in Rails. It coexists with the asset pipeline,
10
14
  as the primary purpose for webpack is app-like JavaScript, not images, CSS, or
11
15
  even JavaScript Sprinkles (that all continues to live in app/assets).
@@ -13,7 +17,7 @@ even JavaScript Sprinkles (that all continues to live in app/assets).
13
17
  However, it is possible to use Webpacker for CSS, images and fonts assets as well,
14
18
  in which case you may not even need the asset pipeline. This is mostly relevant when exclusively using component-based JavaScript frameworks.
15
19
 
16
- **NOTE:** The master branch now hosts the code for v5.x.x. Please refer to [4-x-stable](https://github.com/rails/webpacker/tree/4-x-stable) branch for 4.x documentation.
20
+ **NOTE:** The master branch now hosts the code for v6.x.x. Please refer to [5-x-stable](https://github.com/rails/webpacker/tree/5-x-stable) branch for 5.x documentation.
17
21
 
18
22
  <!-- START doctoc generated TOC please keep comment here to allow auto update -->
19
23
  <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
@@ -28,16 +32,6 @@ in which case you may not even need the asset pipeline. This is mostly relevant
28
32
  - [Webpack Configuration](#webpack-configuration)
29
33
  - [Custom Rails environments](#custom-rails-environments)
30
34
  - [Upgrading](#upgrading)
31
- - [Yarn Integrity](#yarn-integrity)
32
- - [Integrations](#integrations)
33
- - [React](./docs/integrations.md#react)
34
- - [Angular with TypeScript](./docs/integrations.md#angular-with-typescript)
35
- - [Vue](./docs/integrations.md#vue)
36
- - [Elm](./docs/integrations.md#elm)
37
- - [Stimulus](./docs/integrations.md#stimulus)
38
- - [Svelte](./docs/integrations.md#svelte)
39
- - [CoffeeScript](./docs/integrations.md#coffeescript)
40
- - [Erb](./docs/integrations.md#erb)
41
35
  - [Paths](#paths)
42
36
  - [Resolved](#resolved)
43
37
  - [Watched](#watched)
@@ -52,23 +46,28 @@ in which case you may not even need the asset pipeline. This is mostly relevant
52
46
 
53
47
  - Ruby 2.4+
54
48
  - Rails 5.2+
55
- - Node.js 10.13.0+
49
+ - Node.js 10.22.1+ || 12+ || 14+
56
50
  - Yarn 1.x+
57
51
 
58
52
  ## Features
59
53
 
60
- - [webpack 4.x.x](https://webpack.js.org/)
54
+ - [webpack 5.x.x](https://webpack.js.org/)
61
55
  - ES6 with [babel](https://babeljs.io/)
62
56
  - Automatic code splitting using multiple entry points
63
- - Stylesheets - Sass and CSS
64
- - Images and fonts
65
- - PostCSS - Auto-Prefixer
66
57
  - Asset compression, source-maps, and minification
67
58
  - CDN support
68
- - React, Angular, Elm and Vue support out-of-the-box
69
59
  - Rails view helpers
70
60
  - Extensible and configurable
71
61
 
62
+ ### Optional support\*
63
+
64
+ _requires extra packages to be installed_
65
+
66
+ - Stylesheets - SASS, LESS and CSS, PostCSS
67
+ - Coffeescript
68
+ - Typescript
69
+ - React
70
+
72
71
  ## Installation
73
72
 
74
73
  You can either add Webpacker during setup of a new Rails 5.1+ application
@@ -83,12 +82,11 @@ Or add it to your `Gemfile`:
83
82
 
84
83
  ```ruby
85
84
  # Gemfile
86
- gem 'webpacker', '~> 4.x'
85
+ gem 'webpacker', '~> 6.x'
87
86
 
88
87
  # OR if you prefer to use master
89
88
  gem 'webpacker', git: 'https://github.com/rails/webpacker.git'
90
89
  yarn add https://github.com/rails/webpacker.git
91
- yarn add core-js regenerator-runtime
92
90
  ```
93
91
 
94
92
  Finally, run the following to install Webpacker:
@@ -107,6 +105,12 @@ Optional: To fix ["unmet peer dependency" warnings](https://github.com/rails/web
107
105
  yarn upgrade
108
106
  ```
109
107
 
108
+ When `package.json` and/or `yarn.lock` changes, such as when pulling down changes to your local environment in a team settings, be sure to keep your NPM packages up-to-date:
109
+
110
+ ```bash
111
+ yarn install
112
+ ```
113
+
110
114
  ### Usage
111
115
 
112
116
  Once installed, you can start writing modern ES6-flavored JavaScript apps right away:
@@ -116,25 +120,20 @@ app/javascript:
116
120
  ├── packs:
117
121
  │ # only webpack entry files here
118
122
  │ └── application.js
119
- └── src:
120
123
  │ └── application.css
124
+ └── src:
125
+ │ └── my_component.js
126
+ └── stylesheets:
127
+ │ └── my_styles.css
121
128
  └── images:
122
129
  └── logo.svg
123
130
  ```
124
131
 
125
- In `/packs/application.js`, include this at the top of the file:
126
-
127
- ```js
128
- import 'core-js/stable'
129
- import 'regenerator-runtime/runtime'
130
- ```
131
-
132
- You can then link the JavaScript pack in Rails views using the `javascript_pack_tag` helper.
133
- If you have styles imported in your pack file, you can link them by using `stylesheet_pack_tag`:
132
+ You can then link the JavaScript pack in Rails views using the `javascript_packs_with_chunks_tag` helper. If you have styles imported in your pack file, you can link them by using `stylesheet_packs_with_chunks_tag`:
134
133
 
135
134
  ```erb
136
- <%= javascript_pack_tag 'application' %>
137
- <%= stylesheet_pack_tag 'application' %>
135
+ <%= javascript_packs_with_chunks_tag 'application' %>
136
+ <%= stylesheet_packs_with_chunks_tag 'application' %>
138
137
  ```
139
138
 
140
139
  If you want to link a static asset for `<link rel="prefetch">` or `<img />` tag, you
@@ -145,31 +144,6 @@ can use the `asset_pack_path` helper:
145
144
  <img src="<%= asset_pack_path 'images/logo.svg' %>" />
146
145
  ```
147
146
 
148
- If you are using new webpack 4 split chunks API, then consider using `javascript_packs_with_chunks_tag` helper, which creates html
149
- tags for a pack and all the dependent chunks.
150
-
151
- ```erb
152
- <%= javascript_packs_with_chunks_tag 'calendar', 'map', 'data-turbolinks-track': 'reload' %>
153
-
154
- <script src="/packs/vendor-16838bab065ae1e314.js" data-turbolinks-track="reload"></script>
155
- <script src="/packs/calendar~runtime-16838bab065ae1e314.js" data-turbolinks-track="reload"></script>
156
- <script src="/packs/calendar-1016838bab065ae1e314.js" data-turbolinks-track="reload"></script>
157
- <script src="/packs/map~runtime-16838bab065ae1e314.js" data-turbolinks-track="reload"></script>
158
- <script src="/packs/map-16838bab065ae1e314.js" data-turbolinks-track="reload"></script>
159
- ```
160
-
161
- **Important:** Pass all your pack names when using `javascript_packs_with_chunks_tag`
162
- helper otherwise you will get duplicated chunks on the page.
163
-
164
- ```erb
165
- <%# DO %>
166
- <%= javascript_packs_with_chunks_tag 'calendar', 'map' %>
167
-
168
- <%# DON'T %>
169
- <%= javascript_packs_with_chunks_tag 'calendar' %>
170
- <%= javascript_packs_with_chunks_tag 'map' %>
171
- ```
172
-
173
147
  **Note:** In order for your styles or static assets files to be available in your view,
174
148
  you would need to link them in your "pack" or entry file.
175
149
 
@@ -235,7 +209,201 @@ WEBPACKER_DEV_SERVER_HOST=0.0.0.0 ./bin/webpack-dev-server
235
209
 
236
210
  ### Webpack Configuration
237
211
 
238
- See [docs/webpack](docs/webpack.md) for modifying webpack configuration and loaders.
212
+ Webpacker gives you a default set of configuration files for test, development and
213
+ production environments in `config/webpack/*.js`. You can configure each individual
214
+ environment in their respective files or configure them all in the base
215
+ `config/webpack/environment.js` file.
216
+
217
+ By default, you don't need to make any changes to `config/webpack/*.js`
218
+ files since it's all standard production-ready configuration. However,
219
+ if you do need to customize or add a new loader, this is where you would go.
220
+
221
+ Here is how you can modify webpack configuration:
222
+
223
+ You might add separate files to keep your code more organized.
224
+
225
+ ```js
226
+ // config/webpack/custom.js
227
+ module.exports = {
228
+ resolve: {
229
+ alias: {
230
+ jquery: 'jquery/src/jquery',
231
+ vue: 'vue/dist/vue.js',
232
+ React: 'react',
233
+ ReactDOM: 'react-dom',
234
+ vue_resource: 'vue-resource/dist/vue-resource'
235
+ }
236
+ }
237
+ }
238
+ ```
239
+
240
+ Then `require` this file in your `config/webpack/base.js`:
241
+
242
+ ```js
243
+ // config/webpack/base.js
244
+ const { webpackConfig, merge } = require('@rails/webpacker')
245
+ const customConfig = require('./custom')
246
+
247
+ module.exports = merge(webpackConfig, customConfig)
248
+ ```
249
+
250
+ If you need access to configs within Webpacker's configuration,
251
+ you can import them like so:
252
+
253
+ ```js
254
+ // config/webpack/base.js
255
+ const { webpackConfig } = require('@rails/webpacker')
256
+
257
+ console.log(webpackConfig.output_path)
258
+ console.log(webpackConfig.source_path)
259
+ ```
260
+
261
+ ### Integrations
262
+
263
+ Webpacker out of the box supports JS and static assets (fonts, images etc.)
264
+ compilation. To enable support for Coffeescript or Typescript install
265
+ relevant packages,
266
+
267
+ **Coffeescript**
268
+
269
+ ```
270
+ yarn add coffeescript coffee-loader
271
+ ```
272
+
273
+ **Typescript**
274
+
275
+ ```
276
+ yarn add typescript @babel/preset-typescript
277
+ ```
278
+
279
+ Add tsconfig.json
280
+
281
+ ```json
282
+ {
283
+ "compilerOptions": {
284
+ "declaration": false,
285
+ "emitDecoratorMetadata": true,
286
+ "experimentalDecorators": true,
287
+ "lib": ["es6", "dom"],
288
+ "module": "es6",
289
+ "moduleResolution": "node",
290
+ "baseUrl": ".",
291
+ "paths": {
292
+ "*": ["node_modules/*", "app/javascript/*"]
293
+ },
294
+ "sourceMap": true,
295
+ "target": "es5",
296
+ "noEmit": true
297
+ },
298
+ "exclude": ["**/*.spec.ts", "node_modules", "vendor", "public"],
299
+ "compileOnSave": false
300
+ }
301
+ ```
302
+
303
+ #### CSS
304
+
305
+ To enable CSS support in your application, add following packages,
306
+
307
+ ```
308
+ yarn add css-loader mini-css-extract-plugin css-minimizer-webpack-plugin
309
+ ```
310
+
311
+ optionally, add css extension to webpack config for easy resolution
312
+
313
+ ```js
314
+ // config/webpack/base.js
315
+ const { webpackConfig, merge } = require('@rails/webpacker')
316
+ const customConfig = {
317
+ resolve: {
318
+ extensions: ['.css']
319
+ }
320
+ }
321
+
322
+ module.exports = merge(webpackConfig, customConfig)
323
+ ```
324
+
325
+ To enable postcss, sass or less support, add css support first and
326
+ then add the relevant pre-processors:
327
+
328
+ #### Postcss
329
+
330
+ ```
331
+ yarn add postcss-loader
332
+ ```
333
+
334
+ #### Sass
335
+
336
+ ```
337
+ yarn add sass-loader
338
+ ```
339
+
340
+ #### Less
341
+
342
+ ```
343
+ yarn add less-loader
344
+ ```
345
+
346
+ #### React
347
+
348
+ React is supported and you just need to add relevant packages,
349
+
350
+ ```
351
+ yarn add react react-dom @babel/preset-react
352
+ ```
353
+
354
+ if you are using typescript, update your `tsconfig.json`
355
+
356
+ ```json
357
+ {
358
+ "compilerOptions": {
359
+ "declaration": false,
360
+ "emitDecoratorMetadata": true,
361
+ "experimentalDecorators": true,
362
+ "lib": ["es6", "dom"],
363
+ "module": "es6",
364
+ "moduleResolution": "node",
365
+ "sourceMap": true,
366
+ "target": "es5",
367
+ "jsx": "react",
368
+ "noEmit": true
369
+ },
370
+ "exclude": ["**/*.spec.ts", "node_modules", "vendor", "public"],
371
+ "compileOnSave": false
372
+ }
373
+ ```
374
+
375
+ #### Other frameworks
376
+
377
+ Please follow webpack integration guide for relevant framework or library,
378
+
379
+ 1. Svelte - https://github.com/sveltejs/svelte-loader#install
380
+ 2. Angular - https://v2.angular.io/docs/ts/latest/guide/webpack.html#!#configure-webpack
381
+ 3. Vue - https://vue-loader.vuejs.org/guide/
382
+
383
+ For example to add Vue support,
384
+
385
+ ```js
386
+ // config/webpack/rules/vue.js
387
+ const VueLoaderPlugin = require('vue-loader/lib/plugin')
388
+
389
+ module.exports = {
390
+ module: {
391
+ rules: [
392
+ {
393
+ test: /\.vue$/,
394
+ loader: 'vue-loader'
395
+ }
396
+ ]
397
+ },
398
+ plugins: [new VueLoaderPlugin()]
399
+ }
400
+
401
+ // config/webpack/base.js
402
+ const { webpackConfig, merge } = require('@rails/webpacker')
403
+ const vueConfig = require('./rules/vue')
404
+
405
+ module.exports = merge(webpackConfig, vueConfig)
406
+ ```
239
407
 
240
408
  ### Custom Rails environments
241
409
 
@@ -292,7 +460,7 @@ You can run following commands to upgrade Webpacker to the latest stable version
292
460
 
293
461
  ```bash
294
462
  bundle update webpacker
295
- rails webpacker:binstubs
463
+ rails webpacker:install
296
464
  yarn upgrade @rails/webpacker --latest
297
465
  yarn upgrade webpack-dev-server --latest
298
466
 
@@ -300,44 +468,6 @@ yarn upgrade webpack-dev-server --latest
300
468
  yarn add @rails/webpacker@next
301
469
  ```
302
470
 
303
- ### Yarn Integrity
304
-
305
- 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`.
306
-
307
- To turn off this option, you will need to change the default setting in `config/webpacker.yml`:
308
-
309
- ```yaml
310
- # config/webpacker.yml
311
- development:
312
- ...
313
- # Verifies that correct packages and versions are installed by inspecting package.json, yarn.lock, and node_modules
314
- check_yarn_integrity: false
315
- ```
316
-
317
- You may also turn on this feature by adding the config option for any Rails environment in `config/webpacker.yml`:
318
-
319
- ```yaml
320
- check_yarn_integrity: true
321
- ```
322
-
323
- ## Integrations
324
-
325
- Webpacker ships with basic out-of-the-box integration. You can see a list of available commands/tasks by running `bundle exec rails webpacker`.
326
-
327
- Included install integrations:
328
-
329
- - [React](./docs/integrations.md#React)
330
- - [Angular with TypeScript](./docs/integrations.md#Angular-with-TypeScript)
331
- - [Vue](./docs/integrations.md#Vue)
332
- - [Elm](./docs/integrations.md#Elm)
333
- - [Svelte](./docs/integrations.md#Svelte)
334
- - [Stimulus](./docs/integrations.md#Stimulus)
335
- - [CoffeeScript](./docs/integrations.md#CoffeeScript)
336
- - [Typescript](./docs/integrations.md)
337
- - [Erb](./docs/integrations.md#Erb)
338
-
339
- See [Integrations](./docs/integrations.md) for further details.
340
-
341
471
  ## Paths
342
472
 
343
473
  By default, Webpacker ships with simple conventions for where the JavaScript
@@ -373,16 +503,16 @@ development:
373
503
 
374
504
  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.
375
505
 
376
- ### Resolved
506
+ ### Additional paths
377
507
 
378
508
  If you are adding Webpacker to an existing app that has most of the assets inside
379
509
  `app/assets` or inside an engine, and you want to share that
380
- with webpack modules, you can use the `resolved_paths`
510
+ with webpack modules, you can use the `additional_paths`
381
511
  option available in `config/webpacker.yml`. This lets you
382
512
  add additional paths that webpack should lookup when resolving modules:
383
513
 
384
514
  ```yml
385
- resolved_paths: ['app/assets']
515
+ additional_paths: ['app/assets/**/*', 'vendor/assets/**/*.css', 'Gemfile']
386
516
  ```
387
517
 
388
518
  You can then import these items inside your modules like so:
@@ -397,41 +527,11 @@ import 'images/rails.png'
397
527
  will make the compilation slow, consider adding specific paths instead of
398
528
  whole parent directory if you just need to reference one or two modules
399
529
 
400
- ### Watched
401
-
402
- By default, the lazy compilation is cached until a file is changed under your
403
- tracked paths. You can configure which paths are tracked
404
- by adding new paths to `watched_paths` array. This is much like Rails' `autoload_paths`:
405
-
406
- ```rb
407
- # config/initializers/webpacker.rb
408
- # or config/application.rb
409
- Webpacker::Compiler.watched_paths << 'bower_components'
410
- ```
411
-
412
530
  ## Deployment
413
531
 
414
532
  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).
415
533
 
416
- ## Docs
417
-
418
- - [Development](https://github.com/rails/webpacker#development)
419
- - [Webpack](./docs/webpack.md)
420
- - [Webpack-dev-server](./docs/webpack-dev-server.md)
421
- - [Environment Variables](./docs/env.md)
422
- - [Folder Structure](./docs/folder-structure.md)
423
- - [Assets](./docs/assets.md) - [CSS, Sass and SCSS](./docs/css.md) - [ES6](./docs/es6.md)
424
- - [Props](./docs/props.md)
425
- - [Typescript](./docs/typescript.md)
426
- - [Yarn](./docs/yarn.md)
427
- - [Misc](./docs/misc.md)
428
- - [Deployment](./docs/deployment.md)
429
- - [Docker](./docs/docker.md)
430
- - [Using in Rails engines](./docs/engines.md)
431
- - [Webpacker on Cloud9](./docs/cloud9.md)
432
- - [Testing](./docs/testing.md)
433
- - [Troubleshooting](./docs/troubleshooting.md)
434
- - [v3 to v4 Upgrade Guide](./docs/v4-upgrade.md)
534
+ When compiling assets for production on a remote server, such as a continuous integration environment, it's recommended to use `yarn install --frozen-lockfile` to install NPM packages on the remote host to ensure that the installed packages match the `yarn.lock` file.
435
535
 
436
536
  ## Contributing
437
537