webpacker 6.0.0.beta.2 → 6.0.0.beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/jest.yml +1 -1
- data/.github/workflows/js-lint.yml +1 -1
- data/.github/workflows/ruby.yml +9 -6
- data/6_0_upgrade.md +13 -8
- data/CHANGELOG.md +2 -0
- data/CONTRIBUTING.md +1 -1
- data/Gemfile.lock +7 -5
- data/README.md +56 -34
- data/config/README.md +3 -0
- data/config/webpacker.yml +1 -0
- data/lib/install/config/webpacker.yml +4 -2
- data/lib/install/javascript/packs/application.js +1 -1
- data/lib/webpacker/commands.rb +2 -1
- data/lib/webpacker/compiler.rb +2 -2
- data/lib/webpacker/dev_server_runner.rb +2 -0
- data/lib/webpacker/helper.rb +4 -4
- data/lib/webpacker/version.rb +1 -1
- data/lib/webpacker/webpack_runner.rb +1 -0
- data/package.json +1 -1
- data/package/__tests__/development.js +2 -1
- data/package/__tests__/index.js +9 -0
- data/package/environments/__tests__/base.js +4 -4
- data/package/environments/base.js +1 -1
- data/package/environments/development.js +1 -0
- data/package/index.js +3 -3
- data/test/configuration_test.rb +2 -2
- data/test/dev_server_runner_test.rb +10 -2
- data/test/mounted_app/test/dummy/config/webpacker.yml +2 -2
- data/test/test_app/app/{javascript/packs → packs/entrypoints}/application.js +1 -1
- data/test/test_app/app/{javascript/packs → packs/entrypoints}/multi_entry.css +0 -0
- data/test/test_app/app/{javascript/packs → packs/entrypoints}/multi_entry.js +0 -0
- data/test/test_app/config/webpacker.yml +2 -2
- metadata +13 -11
- data/lib/install/javascript/packs/application.css +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab62c5d5a1d4736592168baa8920743203529b76be71a5f551058ab20ee04204
|
4
|
+
data.tar.gz: e992911dd9c65cde8af17479b98b4efde3e12a98196ab586a09320fff9f1c00c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df861ac4efabed724387cd80542f4a1203b47ba93da1e15b232fd323345d9ed7ac7230ca51ffb20f30a046ad57a61dc1be4d45ae613fbfcb6ca3622de5775d7a
|
7
|
+
data.tar.gz: 7a728cb196c75ca876cf407a20e6d2ae1dbf149cbe1755bdf4a698300b0d2ecc7b8f5b827a2a35d07d8cd1ffcd5e8727573319bcb8982239bb04550e8b079776
|
data/.github/workflows/jest.yml
CHANGED
data/.github/workflows/ruby.yml
CHANGED
@@ -18,7 +18,8 @@ jobs:
|
|
18
18
|
2.4,
|
19
19
|
2.5,
|
20
20
|
2.6,
|
21
|
-
2.7
|
21
|
+
2.7,
|
22
|
+
3.0
|
22
23
|
]
|
23
24
|
gemfile: [
|
24
25
|
"gemfiles/Gemfile-rails.5.2.x",
|
@@ -27,13 +28,11 @@ jobs:
|
|
27
28
|
exclude:
|
28
29
|
- ruby: "2.4"
|
29
30
|
gemfile: gemfiles/Gemfile-rails.6.0.x
|
31
|
+
- ruby: "3.0"
|
32
|
+
gemfile: gemfiles/Gemfile-rails.5.2.x
|
30
33
|
experimental: [false]
|
31
34
|
include:
|
32
|
-
- ruby:
|
33
|
-
os: ubuntu-latest
|
34
|
-
gemfile: gemfiles/Gemfile-rails.6.0.x
|
35
|
-
experimental: true
|
36
|
-
- ruby: head
|
35
|
+
- ruby: 2.5
|
37
36
|
os: ubuntu-latest
|
38
37
|
gemfile: gemfiles/Gemfile-rails-edge
|
39
38
|
experimental: true
|
@@ -45,6 +44,10 @@ jobs:
|
|
45
44
|
os: ubuntu-latest
|
46
45
|
gemfile: gemfiles/Gemfile-rails-edge
|
47
46
|
experimental: true
|
47
|
+
- ruby: 3.0
|
48
|
+
os: ubuntu-latest
|
49
|
+
gemfile: gemfiles/Gemfile-rails-edge
|
50
|
+
experimental: true
|
48
51
|
|
49
52
|
steps:
|
50
53
|
- uses: actions/checkout@v2
|
data/6_0_upgrade.md
CHANGED
@@ -6,17 +6,20 @@ straightforward.
|
|
6
6
|
|
7
7
|
## Preparation
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
1. If your `source_path` is `app/javascript`, rename it to `app/packs`
|
10
|
+
2. If your `source_entry_path` is `app/javascript/packs`, rename it to `app/packs/entrypoints`
|
11
|
+
3. Rename `config/webpack` to `config/webpack_old`
|
12
|
+
4. Rename `config/webpacker.yml` to `config/webpacker_old.yml`
|
13
|
+
5. Uninstall the current version of `webpack-dev-server`: `yarn remove webpack-dev-server`
|
14
|
+
6. Upgrade webpacker
|
12
15
|
|
13
16
|
```ruby
|
14
17
|
# Gemfile
|
15
|
-
gem 'webpacker', '~> 6.
|
18
|
+
gem 'webpacker', '~> 6.0.0.pre.2'
|
16
19
|
```
|
17
20
|
|
18
|
-
```
|
19
|
-
bundle
|
21
|
+
```bash
|
22
|
+
bundle install
|
20
23
|
```
|
21
24
|
|
22
25
|
```bash
|
@@ -30,9 +33,9 @@ straightforward.
|
|
30
33
|
- Change `javascript_pack_tag` and `stylesheet_pack_tag` to `javascript_packs_with_chunks_tag` and
|
31
34
|
`stylesheet_packs_with_chunks_tag`
|
32
35
|
|
33
|
-
|
36
|
+
7. If you are using any integrations like `css`, `React` or `TypeScript`. Please see https://github.com/rails/webpacker#integrations section on how they work in v6.0.
|
34
37
|
|
35
|
-
|
38
|
+
8. Copy over any custom webpack config from `config/webpack_old`
|
36
39
|
|
37
40
|
```js
|
38
41
|
// config/webpack/base.js
|
@@ -41,3 +44,5 @@ straightforward.
|
|
41
44
|
|
42
45
|
module.exports = merge(webpackConfig, customConfig)
|
43
46
|
```
|
47
|
+
|
48
|
+
9. Copy over custom browserlist config from `.browserlistrc` if it exists into the `"browserlist"` key in `package.json` and remove `.browserslistrc`.
|
data/CHANGELOG.md
CHANGED
@@ -17,6 +17,8 @@ environment.loaders.append('nodeModules', nodeModules)
|
|
17
17
|
- Changes `@babel/preset-env` modules option to `'auto'` per recommendation in the Babel docs [#2709](https://github.com/rails/webpacker/pull/2709)
|
18
18
|
- Adds experimental Yarn 2 support. Note you must manually set `nodeLinker: node-modules` in your `.yarnrc.yml`.
|
19
19
|
|
20
|
+
- Fixes dev server issues [#2898](https://github.com/rails/webpacker/pull/2898)
|
21
|
+
|
20
22
|
### Breaking changes
|
21
23
|
|
22
24
|
- Simple webpack config
|
data/CONTRIBUTING.md
CHANGED
@@ -9,7 +9,7 @@ yarn
|
|
9
9
|
```
|
10
10
|
|
11
11
|
## Making sure your changes pass all tests
|
12
|
-
There are a number of automated checks which run on
|
12
|
+
There are a number of automated checks which run on GitHub Actions when a pull request is created.
|
13
13
|
You can run those checks on your own locally to make sure that your changes would not break the CI build.
|
14
14
|
|
15
15
|
### 1. Check the code for JavaScript style violations
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
webpacker (6.0.0.beta.
|
4
|
+
webpacker (6.0.0.beta.3)
|
5
5
|
activesupport (>= 5.2)
|
6
6
|
rack-proxy (>= 0.6.1)
|
7
7
|
railties (>= 5.2)
|
@@ -85,14 +85,16 @@ GEM
|
|
85
85
|
method_source (1.0.0)
|
86
86
|
mimemagic (0.3.5)
|
87
87
|
mini_mime (1.0.2)
|
88
|
-
mini_portile2 (2.
|
89
|
-
minitest (5.14.
|
88
|
+
mini_portile2 (2.5.0)
|
89
|
+
minitest (5.14.3)
|
90
90
|
nio4r (2.5.2)
|
91
|
-
nokogiri (1.
|
92
|
-
mini_portile2 (~> 2.
|
91
|
+
nokogiri (1.11.1)
|
92
|
+
mini_portile2 (~> 2.5.0)
|
93
|
+
racc (~> 1.4)
|
93
94
|
parallel (1.19.2)
|
94
95
|
parser (2.7.2.0)
|
95
96
|
ast (~> 2.4.1)
|
97
|
+
racc (1.5.2)
|
96
98
|
rack (2.2.3)
|
97
99
|
rack-proxy (0.6.5)
|
98
100
|
rack
|
data/README.md
CHANGED
@@ -63,9 +63,9 @@ in which case you may not even need the asset pipeline. This is mostly relevant
|
|
63
63
|
|
64
64
|
_requires extra packages to be installed_
|
65
65
|
|
66
|
-
- Stylesheets -
|
67
|
-
-
|
68
|
-
-
|
66
|
+
- Stylesheets - Sass, Less, Stylus and Css, PostCSS
|
67
|
+
- CoffeeScript
|
68
|
+
- TypeScript
|
69
69
|
- React
|
70
70
|
|
71
71
|
## Installation
|
@@ -116,9 +116,9 @@ yarn install
|
|
116
116
|
Once installed, you can start writing modern ES6-flavored JavaScript apps right away:
|
117
117
|
|
118
118
|
```yml
|
119
|
-
app/
|
120
|
-
├──
|
121
|
-
│ #
|
119
|
+
app/packs:
|
120
|
+
├── entrypoints:
|
121
|
+
│ # Only webpack entry files here
|
122
122
|
│ └── application.js
|
123
123
|
│ └── application.css
|
124
124
|
└── src:
|
@@ -136,16 +136,37 @@ You can then link the JavaScript pack in Rails views using the `javascript_packs
|
|
136
136
|
<%= stylesheet_packs_with_chunks_tag 'application' %>
|
137
137
|
```
|
138
138
|
|
139
|
-
If you want to link a static asset for `<
|
140
|
-
can use the `asset_pack_path` helper:
|
141
|
-
|
139
|
+
If you want to link a static asset for `<img />` tag, you can use the `asset_pack_path` helper:
|
142
140
|
```erb
|
143
|
-
<link rel="prefetch" href="<%= asset_pack_path 'application.css' %>" />
|
144
141
|
<img src="<%= asset_pack_path 'images/logo.svg' %>" />
|
145
142
|
```
|
146
143
|
|
144
|
+
Or use the dedicated helper:
|
145
|
+
```erb
|
146
|
+
<%= image_pack_tag 'application.png', size: '16x10', alt: 'Edit Entry' %>
|
147
|
+
<%= image_pack_tag 'picture.png', srcset: { 'picture-2x.png' => '2x' } %>
|
148
|
+
```
|
149
|
+
|
150
|
+
If you want to create a favicon:
|
151
|
+
```erb
|
152
|
+
<%= favicon_pack_tag 'mb-icon.png', rel: 'apple-touch-icon', type: 'image/png' %>
|
153
|
+
```
|
154
|
+
|
155
|
+
If you want to preload a static asset in your `<head>`, you can use the `preload_pack_asset` helper:
|
156
|
+
```erb
|
157
|
+
<%= preload_pack_asset 'fonts/fa-regular-400.woff2' %>
|
158
|
+
```
|
159
|
+
|
160
|
+
If you want to use images in your stylesheets:
|
161
|
+
|
162
|
+
```css
|
163
|
+
.foo {
|
164
|
+
background-image: url('../images/logo.svg')
|
165
|
+
}
|
166
|
+
```
|
167
|
+
|
147
168
|
**Note:** In order for your styles or static assets files to be available in your view,
|
148
|
-
you would need to link them in your
|
169
|
+
you would need to link them in your `pack` or entry file.
|
149
170
|
|
150
171
|
### Development
|
151
172
|
|
@@ -161,7 +182,7 @@ to the standard Rails log.
|
|
161
182
|
|
162
183
|
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
|
163
184
|
in a terminal separate from `bundle exec rails s`. This process will watch for changes
|
164
|
-
in the `app/
|
185
|
+
in the `app/packs/entrypoints/*.js` files and automatically reload the browser to match.
|
165
186
|
|
166
187
|
```bash
|
167
188
|
# webpack dev server
|
@@ -212,7 +233,7 @@ WEBPACKER_DEV_SERVER_HOST=0.0.0.0 ./bin/webpack-dev-server
|
|
212
233
|
Webpacker gives you a default set of configuration files for test, development and
|
213
234
|
production environments in `config/webpack/*.js`. You can configure each individual
|
214
235
|
environment in their respective files or configure them all in the base
|
215
|
-
`config/webpack/
|
236
|
+
`config/webpack/base.js` file.
|
216
237
|
|
217
238
|
By default, you don't need to make any changes to `config/webpack/*.js`
|
218
239
|
files since it's all standard production-ready configuration. However,
|
@@ -261,18 +282,18 @@ console.log(webpackConfig.source_path)
|
|
261
282
|
### Integrations
|
262
283
|
|
263
284
|
Webpacker out of the box supports JS and static assets (fonts, images etc.)
|
264
|
-
compilation. To enable support for
|
285
|
+
compilation. To enable support for CoffeeScript or TypeScript install
|
265
286
|
relevant packages,
|
266
287
|
|
267
|
-
|
288
|
+
#### CoffeeScript
|
268
289
|
|
269
|
-
```
|
290
|
+
```bash
|
270
291
|
yarn add coffeescript coffee-loader
|
271
292
|
```
|
272
293
|
|
273
|
-
|
294
|
+
#### TypeScript
|
274
295
|
|
275
|
-
```
|
296
|
+
```bash
|
276
297
|
yarn add typescript @babel/preset-typescript
|
277
298
|
```
|
278
299
|
|
@@ -289,7 +310,7 @@ Add tsconfig.json
|
|
289
310
|
"moduleResolution": "node",
|
290
311
|
"baseUrl": ".",
|
291
312
|
"paths": {
|
292
|
-
"*": ["node_modules/*", "app/
|
313
|
+
"*": ["node_modules/*", "app/packs/*"]
|
293
314
|
},
|
294
315
|
"sourceMap": true,
|
295
316
|
"target": "es5",
|
@@ -304,7 +325,7 @@ Add tsconfig.json
|
|
304
325
|
|
305
326
|
To enable CSS support in your application, add following packages,
|
306
327
|
|
307
|
-
```
|
328
|
+
```bash
|
308
329
|
yarn add css-loader mini-css-extract-plugin css-minimizer-webpack-plugin
|
309
330
|
```
|
310
331
|
|
@@ -327,25 +348,25 @@ then add the relevant pre-processors:
|
|
327
348
|
|
328
349
|
#### Postcss
|
329
350
|
|
330
|
-
```
|
351
|
+
```bash
|
331
352
|
yarn add postcss-loader
|
332
353
|
```
|
333
354
|
|
334
355
|
#### Sass
|
335
356
|
|
336
|
-
```
|
357
|
+
```bash
|
337
358
|
yarn add sass sass-loader
|
338
359
|
```
|
339
360
|
|
340
361
|
#### Less
|
341
362
|
|
342
|
-
```
|
363
|
+
```bash
|
343
364
|
yarn add less less-loader
|
344
365
|
```
|
345
366
|
|
346
|
-
####
|
367
|
+
#### Stylus
|
347
368
|
|
348
|
-
```
|
369
|
+
```bash
|
349
370
|
yarn add stylus stylus-loader
|
350
371
|
```
|
351
372
|
|
@@ -353,7 +374,7 @@ yarn add stylus stylus-loader
|
|
353
374
|
|
354
375
|
React is supported and you just need to add relevant packages,
|
355
376
|
|
356
|
-
```
|
377
|
+
```bash
|
357
378
|
yarn add react react-dom @babel/preset-react
|
358
379
|
```
|
359
380
|
|
@@ -382,12 +403,11 @@ if you are using typescript, update your `tsconfig.json`
|
|
382
403
|
|
383
404
|
Please follow webpack integration guide for relevant framework or library,
|
384
405
|
|
385
|
-
1. Svelte
|
386
|
-
2. Angular
|
387
|
-
3. Vue
|
388
|
-
|
389
|
-
For example to add Vue support,
|
406
|
+
1. [Svelte](https://github.com/sveltejs/svelte-loader#install)
|
407
|
+
2. [Angular](https://v2.angular.io/docs/ts/latest/guide/webpack.html#!#configure-webpack)
|
408
|
+
3. [Vue](https://vue-loader.vuejs.org/guide/)
|
390
409
|
|
410
|
+
For example to add Vue support:
|
391
411
|
```js
|
392
412
|
// config/webpack/rules/vue.js
|
393
413
|
const VueLoaderPlugin = require('vue-loader/lib/plugin')
|
@@ -403,7 +423,9 @@ module.exports = {
|
|
403
423
|
},
|
404
424
|
plugins: [new VueLoaderPlugin()]
|
405
425
|
}
|
426
|
+
```
|
406
427
|
|
428
|
+
```js
|
407
429
|
// config/webpack/base.js
|
408
430
|
const { webpackConfig, merge } = require('@rails/webpacker')
|
409
431
|
const vueConfig = require('./rules/vue')
|
@@ -481,13 +503,13 @@ app files and compiled webpack bundles will go in your Rails app.
|
|
481
503
|
All these options are configurable from `config/webpacker.yml` file.
|
482
504
|
|
483
505
|
The configuration for what webpack is supposed to compile by default rests
|
484
|
-
on the convention that every file in `app/
|
506
|
+
on the convention that every file in `app/packs/entrypoints/*`**(default)**
|
485
507
|
or whatever path you set for `source_entry_path` in the `webpacker.yml` configuration
|
486
508
|
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
|
487
509
|
an entry file. As a rule of thumb, put all files you want to link in your views inside
|
488
|
-
"packs" directory and keep everything else under `app/
|
510
|
+
"packs" directory and keep everything else under `app/packs`.
|
489
511
|
|
490
|
-
Suppose you want to change the source directory from `app/
|
512
|
+
Suppose you want to change the source directory from `app/packs`
|
491
513
|
to `frontend` and output to `assets/packs`. This is how you would do it:
|
492
514
|
|
493
515
|
```yml
|
data/config/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
config/lib/install/config/webpacker.yml
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# Note: You must restart bin/webpack-dev-server for changes to take effect
|
2
2
|
|
3
3
|
default: &default
|
4
|
-
source_path: app/
|
5
|
-
source_entry_path:
|
4
|
+
source_path: app/packs
|
5
|
+
source_entry_path: entrypoints
|
6
6
|
public_root_path: public
|
7
7
|
public_output_path: packs
|
8
8
|
cache_path: tmp/cache/webpacker
|
@@ -25,6 +25,8 @@ development:
|
|
25
25
|
host: localhost
|
26
26
|
port: 3035
|
27
27
|
public: localhost:3035
|
28
|
+
# Inject browserside javascript that required by both HMR and Live(full) reload
|
29
|
+
inject_client: true
|
28
30
|
# Hot Module Replacement updates modules while the application is running without a full reload
|
29
31
|
hmr: false
|
30
32
|
# Inline should be set to true if using HMR; it inserts a script to take care of live reloading
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/* eslint no-console:0 */
|
2
2
|
// This file is automatically compiled by Webpack, along with any other files
|
3
3
|
// present in this directory. You're encouraged to place your actual application logic in
|
4
|
-
// a relevant structure within app/
|
4
|
+
// a relevant structure within app/packs and only use these pack files to reference
|
5
5
|
// that code so it'll be compiled.
|
6
6
|
//
|
7
7
|
// To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate
|
data/lib/webpacker/commands.rb
CHANGED
@@ -64,7 +64,8 @@ class Webpacker::Commands
|
|
64
64
|
|
65
65
|
def current_version
|
66
66
|
packs = manifest.refresh.values.map do |value|
|
67
|
-
|
67
|
+
value = value["src"] if value.is_a?(Hash)
|
68
|
+
next unless value.is_a?(String)
|
68
69
|
|
69
70
|
File.join(config.root_path, "public", "#{value}*")
|
70
71
|
end.compact
|
data/lib/webpacker/compiler.rb
CHANGED
@@ -35,7 +35,7 @@ class Webpacker::Compiler
|
|
35
35
|
|
36
36
|
# Returns true if all the compiled packs are up to date with the underlying asset files.
|
37
37
|
def fresh?
|
38
|
-
watched_files_digest
|
38
|
+
last_compilation_digest&.== watched_files_digest
|
39
39
|
end
|
40
40
|
|
41
41
|
# Returns true if the compiled packs are out of date with the underlying asset files.
|
@@ -69,7 +69,7 @@ class Webpacker::Compiler
|
|
69
69
|
bin_webpack_path = config.root_path.join("bin/webpack")
|
70
70
|
first_line = File.readlines(bin_webpack_path).first.chomp
|
71
71
|
/ruby/.match?(first_line) ? RbConfig.ruby : ""
|
72
|
-
|
72
|
+
end
|
73
73
|
|
74
74
|
def run_webpack
|
75
75
|
logger.info "Compiling..."
|
@@ -64,6 +64,7 @@ module Webpacker
|
|
64
64
|
def execute_cmd
|
65
65
|
env = Webpacker::Compiler.env
|
66
66
|
env["WEBPACKER_CONFIG"] = @webpacker_config
|
67
|
+
env["WEBPACK_DEV_SERVER"] = "true"
|
67
68
|
|
68
69
|
cmd = if node_modules_bin_exist?
|
69
70
|
["#{@node_modules_bin_path}/webpack", "serve"]
|
@@ -73,6 +74,7 @@ module Webpacker
|
|
73
74
|
|
74
75
|
if @argv.include?("--debug-webpacker")
|
75
76
|
cmd = [ "node", "--inspect-brk"] + cmd
|
77
|
+
@argv.delete "--debug-webpacker"
|
76
78
|
end
|
77
79
|
|
78
80
|
cmd += ["--config", @webpack_config]
|
data/lib/webpacker/helper.rb
CHANGED
@@ -74,7 +74,7 @@ module Webpacker::Helper
|
|
74
74
|
|
75
75
|
# Creates a script tag that references the named pack file, as compiled by webpack per the entries list
|
76
76
|
# in package/environments/base.js. By default, this list is auto-generated to match everything in
|
77
|
-
# app/
|
77
|
+
# app/packs/entrypoints/*.js. In production mode, the digested reference is automatically looked up.
|
78
78
|
#
|
79
79
|
# Example:
|
80
80
|
#
|
@@ -87,7 +87,7 @@ module Webpacker::Helper
|
|
87
87
|
# Creates script tags that reference the js chunks from entrypoints when using split chunks API,
|
88
88
|
# as compiled by webpack per the entries list in package/environments/base.js.
|
89
89
|
# By default, this list is auto-generated to match everything in
|
90
|
-
# app/
|
90
|
+
# app/packs/entrypoints/*.js and all the dependent chunks. In production mode, the digested reference is automatically looked up.
|
91
91
|
# See: https://webpack.js.org/plugins/split-chunks-plugin/
|
92
92
|
#
|
93
93
|
# Example:
|
@@ -129,7 +129,7 @@ module Webpacker::Helper
|
|
129
129
|
|
130
130
|
# Creates a link tag that references the named pack file, as compiled by webpack per the entries list
|
131
131
|
# in package/environments/base.js. By default, this list is auto-generated to match everything in
|
132
|
-
# app/
|
132
|
+
# app/packs/entrypoints/*.js. In production mode, the digested reference is automatically looked up.
|
133
133
|
#
|
134
134
|
# Note: If the development server is running and hot module replacement is active, this will return nothing.
|
135
135
|
# In that setup you need to configure your styles to be inlined in your JavaScript for hot reloading.
|
@@ -145,7 +145,7 @@ module Webpacker::Helper
|
|
145
145
|
# Creates link tags that reference the css chunks from entrypoints when using split chunks API,
|
146
146
|
# as compiled by webpack per the entries list in package/environments/base.js.
|
147
147
|
# By default, this list is auto-generated to match everything in
|
148
|
-
# app/
|
148
|
+
# app/packs/entrypoints/*.js and all the dependent chunks. In production mode, the digested reference is automatically looked up.
|
149
149
|
# See: https://webpack.js.org/plugins/split-chunks-plugin/
|
150
150
|
#
|
151
151
|
# Examples:
|
data/lib/webpacker/version.rb
CHANGED
data/package.json
CHANGED
@@ -0,0 +1,9 @@
|
|
1
|
+
const index = require('../index')
|
2
|
+
|
3
|
+
describe('index', () => {
|
4
|
+
test('exports webpack-merge v5 functions', () => {
|
5
|
+
expect(index.merge).toBeInstanceOf(Function)
|
6
|
+
expect(index.mergeWithRules).toBeInstanceOf(Function)
|
7
|
+
expect(index.mergeWithCustomize).toBeInstanceOf(Function)
|
8
|
+
})
|
9
|
+
})
|
@@ -17,14 +17,14 @@ describe('Base config', () => {
|
|
17
17
|
describe('config', () => {
|
18
18
|
test('should return entry', () => {
|
19
19
|
expect(baseConfig.entry.application).toEqual(
|
20
|
-
resolve('app', '
|
20
|
+
resolve('app', 'packs', 'entrypoints', 'application.js')
|
21
21
|
)
|
22
22
|
})
|
23
23
|
|
24
24
|
test('should return multi file entry points', () => {
|
25
25
|
expect(baseConfig.entry.multi_entry.sort()).toEqual([
|
26
|
-
resolve('app', '
|
27
|
-
resolve('app', '
|
26
|
+
resolve('app', 'packs', 'entrypoints', 'multi_entry.css'),
|
27
|
+
resolve('app', 'packs', 'entrypoints', 'multi_entry.js')
|
28
28
|
])
|
29
29
|
})
|
30
30
|
|
@@ -53,7 +53,7 @@ describe('Base config', () => {
|
|
53
53
|
|
54
54
|
test('should return default resolve.modules with additions', () => {
|
55
55
|
expect(baseConfig.resolve.modules).toEqual([
|
56
|
-
resolve('app', '
|
56
|
+
resolve('app', 'packs'),
|
57
57
|
resolve('app/assets'),
|
58
58
|
resolve('/etc/yarn'),
|
59
59
|
resolve('some.config.js'),
|
data/package/index.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/* eslint global-require: 0 */
|
2
2
|
/* eslint import/no-dynamic-require: 0 */
|
3
3
|
|
4
|
-
const
|
4
|
+
const webpackMerge = require('webpack-merge')
|
5
5
|
const { resolve } = require('path')
|
6
6
|
const { existsSync } = require('fs')
|
7
7
|
const baseConfig = require('./environments/base')
|
@@ -23,7 +23,7 @@ module.exports = {
|
|
23
23
|
webpackConfig: webpackConfig(),
|
24
24
|
baseConfig,
|
25
25
|
rules,
|
26
|
-
merge,
|
27
26
|
moduleExists,
|
28
|
-
canProcess
|
27
|
+
canProcess,
|
28
|
+
...webpackMerge
|
29
29
|
}
|
data/test/configuration_test.rb
CHANGED
@@ -10,12 +10,12 @@ class ConfigurationTest < Webpacker::Test
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_source_path
|
13
|
-
source_path = File.expand_path File.join(File.dirname(__FILE__), "test_app/app/
|
13
|
+
source_path = File.expand_path File.join(File.dirname(__FILE__), "test_app/app/packs").to_s
|
14
14
|
assert_equal source_path, @config.source_path.to_s
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_source_entry_path
|
18
|
-
source_entry_path = File.expand_path File.join(File.dirname(__FILE__), "test_app/app/
|
18
|
+
source_entry_path = File.expand_path File.join(File.dirname(__FILE__), "test_app/app/packs", "entrypoints").to_s
|
19
19
|
assert_equal @config.source_entry_path.to_s, source_entry_path
|
20
20
|
end
|
21
21
|
|
@@ -43,19 +43,27 @@ class DevServerRunnerTest < Webpacker::Test
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
+
def test_environment_variables
|
47
|
+
cmd = ["#{test_app_path}/node_modules/.bin/webpack", "serve", "--config", "#{test_app_path}/config/webpack/development.js"]
|
48
|
+
env = Webpacker::Compiler.env.dup
|
49
|
+
env["WEBPACKER_CONFIG"] = "#{test_app_path}/config/webpacker.yml"
|
50
|
+
env["WEBPACK_DEV_SERVER"] = "true"
|
51
|
+
verify_command(cmd, env: env)
|
52
|
+
end
|
53
|
+
|
46
54
|
private
|
47
55
|
def test_app_path
|
48
56
|
File.expand_path("test_app", __dir__)
|
49
57
|
end
|
50
58
|
|
51
|
-
def verify_command(cmd, use_node_modules: true, argv: [])
|
59
|
+
def verify_command(cmd, use_node_modules: true, argv: [], env: Webpacker::Compiler.env)
|
52
60
|
cwd = Dir.pwd
|
53
61
|
Dir.chdir(test_app_path)
|
54
62
|
|
55
63
|
klass = Webpacker::DevServerRunner
|
56
64
|
instance = klass.new(argv)
|
57
65
|
mock = Minitest::Mock.new
|
58
|
-
mock.expect(:call, nil, [
|
66
|
+
mock.expect(:call, nil, [env, *cmd])
|
59
67
|
|
60
68
|
klass.stub(:new, instance) do
|
61
69
|
instance.stub(:node_modules_bin_exist?, use_node_modules) do
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# Note: You must restart bin/webpack-dev-server for changes to take effect
|
2
2
|
|
3
3
|
default: &default
|
4
|
-
source_path: app/
|
5
|
-
source_entry_path:
|
4
|
+
source_path: app/packs
|
5
|
+
source_entry_path: entrypoints
|
6
6
|
public_output_path: packs
|
7
7
|
cache_path: tmp/cache/webpacker
|
8
8
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/* eslint no-console:0 */
|
2
2
|
// This file is automatically compiled by Webpack, along with any other files
|
3
3
|
// present in this directory. You're encouraged to place your actual application logic in
|
4
|
-
// a relevant structure within app/
|
4
|
+
// a relevant structure within app/packs and only use these pack files to reference
|
5
5
|
// that code so it'll be compiled.
|
6
6
|
//
|
7
7
|
// To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate
|
File without changes
|
File without changes
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# Note: You must restart bin/webpack-dev-server for changes to take effect
|
2
2
|
|
3
3
|
default: &default
|
4
|
-
source_path: app/
|
5
|
-
source_entry_path:
|
4
|
+
source_path: app/packs
|
5
|
+
source_entry_path: entrypoints
|
6
6
|
public_root_path: public
|
7
7
|
public_output_path: packs
|
8
8
|
cache_path: tmp/cache/webpacker
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webpacker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.0.0.beta.
|
4
|
+
version: 6.0.0.beta.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-01-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -134,6 +134,8 @@ files:
|
|
134
134
|
- MIT-LICENSE
|
135
135
|
- README.md
|
136
136
|
- Rakefile
|
137
|
+
- config/README.md
|
138
|
+
- config/webpacker.yml
|
137
139
|
- gemfiles/Gemfile-rails-edge
|
138
140
|
- gemfiles/Gemfile-rails.5.2.x
|
139
141
|
- gemfiles/Gemfile-rails.6.0.x
|
@@ -145,7 +147,6 @@ files:
|
|
145
147
|
- lib/install/config/webpack/production.js
|
146
148
|
- lib/install/config/webpack/test.js
|
147
149
|
- lib/install/config/webpacker.yml
|
148
|
-
- lib/install/javascript/packs/application.css
|
149
150
|
- lib/install/javascript/packs/application.js
|
150
151
|
- lib/install/template.rb
|
151
152
|
- lib/tasks/webpacker.rake
|
@@ -180,6 +181,7 @@ files:
|
|
180
181
|
- package/__tests__/dev_server.js
|
181
182
|
- package/__tests__/development.js
|
182
183
|
- package/__tests__/env.js
|
184
|
+
- package/__tests__/index.js
|
183
185
|
- package/__tests__/production.js
|
184
186
|
- package/__tests__/staging.js
|
185
187
|
- package/__tests__/test.js
|
@@ -226,9 +228,9 @@ files:
|
|
226
228
|
- test/mounted_app/test/dummy/package.json
|
227
229
|
- test/rake_tasks_test.rb
|
228
230
|
- test/test_app/Rakefile
|
229
|
-
- test/test_app/app/
|
230
|
-
- test/test_app/app/
|
231
|
-
- test/test_app/app/
|
231
|
+
- test/test_app/app/packs/entrypoints/application.js
|
232
|
+
- test/test_app/app/packs/entrypoints/multi_entry.css
|
233
|
+
- test/test_app/app/packs/entrypoints/multi_entry.js
|
232
234
|
- test/test_app/bin/webpack
|
233
235
|
- test/test_app/bin/webpack-dev-server
|
234
236
|
- test/test_app/config.ru
|
@@ -250,8 +252,8 @@ homepage: https://github.com/rails/webpacker
|
|
250
252
|
licenses:
|
251
253
|
- MIT
|
252
254
|
metadata:
|
253
|
-
source_code_uri: https://github.com/rails/webpacker/tree/v6.0.0.beta.
|
254
|
-
changelog_uri: https://github.com/rails/webpacker/blob/v6.0.0.beta.
|
255
|
+
source_code_uri: https://github.com/rails/webpacker/tree/v6.0.0.beta.3
|
256
|
+
changelog_uri: https://github.com/rails/webpacker/blob/v6.0.0.beta.3/CHANGELOG.md
|
255
257
|
post_install_message:
|
256
258
|
rdoc_options: []
|
257
259
|
require_paths:
|
@@ -292,9 +294,9 @@ test_files:
|
|
292
294
|
- test/mounted_app/test/dummy/package.json
|
293
295
|
- test/rake_tasks_test.rb
|
294
296
|
- test/test_app/Rakefile
|
295
|
-
- test/test_app/app/
|
296
|
-
- test/test_app/app/
|
297
|
-
- test/test_app/app/
|
297
|
+
- test/test_app/app/packs/entrypoints/application.js
|
298
|
+
- test/test_app/app/packs/entrypoints/multi_entry.css
|
299
|
+
- test/test_app/app/packs/entrypoints/multi_entry.js
|
298
300
|
- test/test_app/bin/webpack
|
299
301
|
- test/test_app/bin/webpack-dev-server
|
300
302
|
- test/test_app/config.ru
|
@@ -1,9 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
Any CSS added to this file or imported from this file, e.g. `@import '../stylesheets/my-css.css'`,
|
3
|
-
will be included in the "application" pack. Any CSS imported from application.js or as part of the
|
4
|
-
application.js dependency graph, e.g. `import '../stylesheets/my-css.css'` will also be included
|
5
|
-
in the "application" pack.
|
6
|
-
|
7
|
-
To reference this file, add <%= stylesheet_pack_tag 'application' %> to the appropriate
|
8
|
-
layout file, like app/views/layouts/application.html.erb
|
9
|
-
*/
|