webpacker 6.0.0.beta.2 → 6.0.0.beta.7
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/.rubocop.yml +105 -0
- data/CHANGELOG.md +6 -4
- data/CONTRIBUTING.md +1 -1
- data/Gemfile.lock +93 -90
- data/README.md +133 -58
- data/config/README.md +3 -0
- data/config/webpacker.yml +1 -0
- data/docs/deployment.md +128 -0
- data/docs/troubleshooting.md +160 -0
- data/docs/v6_upgrade.md +86 -0
- data/lib/install/config/webpacker.yml +5 -3
- data/lib/install/{javascript/packs → packs/entrypoints}/application.js +1 -1
- data/lib/install/template.rb +16 -9
- data/lib/tasks/webpacker/binstubs.rake +2 -2
- data/lib/tasks/webpacker/check_node.rake +1 -0
- data/lib/tasks/webpacker/check_yarn.rake +1 -0
- data/lib/tasks/webpacker/install.rake +2 -2
- data/lib/webpacker/commands.rb +2 -1
- data/lib/webpacker/compiler.rb +2 -2
- data/lib/webpacker/configuration.rb +4 -4
- data/lib/webpacker/dev_server_runner.rb +2 -0
- data/lib/webpacker/helper.rb +13 -43
- data/lib/webpacker/manifest.rb +1 -1
- 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 +3 -8
- data/package/environments/development.js +1 -0
- data/package/environments/production.js +1 -1
- data/package/index.js +3 -3
- data/package/rules/babel.js +1 -1
- data/package/rules/stylus.js +1 -1
- data/package/utils/helpers.js +4 -2
- data/test/configuration_test.rb +2 -2
- data/test/dev_server_runner_test.rb +10 -2
- data/test/helper_test.rb +33 -39
- data/test/manifest_test.rb +8 -0
- data/test/mounted_app/test/dummy/config/webpacker.yml +3 -3
- 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 +3 -3
- data/test/test_app/public/packs/manifest.json +7 -0
- metadata +18 -14
- data/6_0_upgrade.md +0 -43
- data/lib/install/javascript/packs/application.css +0 -9
@@ -0,0 +1,160 @@
|
|
1
|
+
# Troubleshooting
|
2
|
+
|
3
|
+
## Debugging your webpack config
|
4
|
+
|
5
|
+
1. Read the error message carefully. The error message will tell you the precise key value
|
6
|
+
that is not matching what Webpack expects.
|
7
|
+
2. Put a `debugger` statement in your Webpack configuration and run `bin/webpack --debug-webpacker`.
|
8
|
+
If you have a node debugger installed, you'll see the Chrome debugger for your webpack
|
9
|
+
config. For example, install the Chrome extension
|
10
|
+
[NiM](https://chrome.google.com/webstore/detail/nodejs-v8-inspector-manag/gnhhdgbaldcilmgcpfddgdbkhjohddkj) and
|
11
|
+
set the option for the dev tools to open automatically. Or put `chrome://inspect` in the URL bar.
|
12
|
+
For more details on debugging, see the official
|
13
|
+
[Webpack docs on debugging](https://webpack.js.org/contribute/debugging/#devtools)
|
14
|
+
3. Any arguments that you add to bin/webpack get sent to webpack. For example, you can pass `--debug` to switch loaders to debug mode. See [webpack CLI debug options](https://webpack.js.org/api/cli/#debug-options) for more information on the available options.
|
15
|
+
4. You can also pass additional options to the command to run the webpack-dev-server and start the webpack-dev-server with the option `--debug-webpacker`
|
16
|
+
|
17
|
+
## ENOENT: no such file or directory - node-sass
|
18
|
+
|
19
|
+
If you get the error `ENOENT: no such file or directory - node-sass` on deploy with
|
20
|
+
`assets:precompile` or `bundle exec rails webpacker:compile` you may need to
|
21
|
+
move Sass to production `dependencies`.
|
22
|
+
|
23
|
+
Move any packages that related to Sass (e.g. `node-sass` or `sass-loader`) from
|
24
|
+
`devDependencies` to `dependencies` in `package.json`. This is because
|
25
|
+
webpacker is running on a production system with the Rails workflow to build
|
26
|
+
the assets. Particularly on hosting providers that try to detect and do the right
|
27
|
+
thing, like Heroku.
|
28
|
+
|
29
|
+
However, if you get this on local development, or not during a deploy then you
|
30
|
+
may need to rebuild `node-sass`. It's a bit of a weird error; basically, it
|
31
|
+
can't find the `node-sass` binary. An easy solution is to create a postinstall
|
32
|
+
hook to ensure `node-sass` is rebuilt whenever new modules are installed.
|
33
|
+
|
34
|
+
In `package.json`:
|
35
|
+
|
36
|
+
```json
|
37
|
+
"scripts": {
|
38
|
+
"postinstall": "npm rebuild node-sass"
|
39
|
+
}
|
40
|
+
```
|
41
|
+
|
42
|
+
## Can't find hello_react.js in manifest.json
|
43
|
+
|
44
|
+
* If you get this error `Can't find hello_react.js in manifest.json`
|
45
|
+
when loading a view in the browser it's because webpack is still compiling packs.
|
46
|
+
Webpacker uses a `manifest.json` file to keep track of packs in all environments,
|
47
|
+
however since this file is generated after packs are compiled by webpack. So,
|
48
|
+
if you load a view in browser whilst webpack is compiling you will get this error.
|
49
|
+
Therefore, make sure webpack
|
50
|
+
(i.e `./bin/webpack-dev-server`) is running and has
|
51
|
+
completed the compilation successfully before loading a view.
|
52
|
+
|
53
|
+
|
54
|
+
## throw er; // Unhandled 'error' event
|
55
|
+
|
56
|
+
* If you get this error while trying to use Elm, try rebuilding Elm. You can do
|
57
|
+
so with a postinstall hook in your `package.json`:
|
58
|
+
|
59
|
+
```
|
60
|
+
"scripts": {
|
61
|
+
"postinstall": "npm rebuild elm"
|
62
|
+
}
|
63
|
+
```
|
64
|
+
|
65
|
+
|
66
|
+
## webpack or webpack-dev-server not found
|
67
|
+
|
68
|
+
* This could happen if `webpacker:install` step is skipped. Please run `bundle exec rails webpacker:install` to fix the issue.
|
69
|
+
|
70
|
+
* If you encounter the above error on heroku after upgrading from Rails 4.x to 5.1.x, then the problem might be related to missing `yarn` binstub. Please run following commands to update/add binstubs:
|
71
|
+
|
72
|
+
```bash
|
73
|
+
bundle config --delete bin
|
74
|
+
./bin/rails app:update:bin # or rails app:update:bin
|
75
|
+
```
|
76
|
+
|
77
|
+
|
78
|
+
## Running webpack on Windows
|
79
|
+
|
80
|
+
If you are running webpack on Windows, your command shell may not be able to interpret the preferred interpreter
|
81
|
+
for the scripts generated in `bin/webpack` and `bin/webpack-dev-server`. Instead you'll want to run the scripts
|
82
|
+
manually with Ruby:
|
83
|
+
|
84
|
+
```
|
85
|
+
C:\path>ruby bin\webpack
|
86
|
+
C:\path>ruby bin\webpack-dev-server
|
87
|
+
```
|
88
|
+
|
89
|
+
|
90
|
+
## Invalid configuration object. webpack has been initialised using a configuration object that does not match the API schema.
|
91
|
+
|
92
|
+
If you receive this error when running `$ ./bin/webpack-dev-server` ensure your configuration is correct; most likely the path to your "packs" folder is incorrect if you modified from the original "source_path" defined in `config/webpacker.yml`.
|
93
|
+
|
94
|
+
## Running Elm on Continuous Integration (CI) services such as CircleCI, CodeShip, Travis CI
|
95
|
+
|
96
|
+
If your tests are timing out or erroring on CI it is likely that you are experiencing the slow Elm compilation issue described here: [elm-compiler issue #1473](https://github.com/elm-lang/elm-compiler/issues/1473)
|
97
|
+
|
98
|
+
The issue is related to CPU count exposed by the underlying service. The basic solution involves using [libsysconfcpus](https://github.com/obmarg/libsysconfcpus) to change the reported CPU count.
|
99
|
+
|
100
|
+
Basic fix involves:
|
101
|
+
|
102
|
+
```bash
|
103
|
+
# install sysconfcpus on CI
|
104
|
+
git clone https://github.com/obmarg/libsysconfcpus.git $HOME/dependencies/libsysconfcpus
|
105
|
+
cd libsysconfcpus
|
106
|
+
.configure --prefix=$HOME/dependencies/sysconfcpus
|
107
|
+
make && make install
|
108
|
+
|
109
|
+
# use sysconfcpus with elm-make
|
110
|
+
mv $HOME/your_rails_app/node_modules/.bin/elm-make $HOME/your_rails_app/node_modules/.bin/elm-make-old
|
111
|
+
printf "#\041/bin/bash\n\necho \"Running elm-make with sysconfcpus -n 2\"\n\n$HOME/dependencies/sysconfcpus/bin/sysconfcpus -n 2 $HOME/your_rails_app/node_modules/.bin/elm-make-old \"\$@\"" > $HOME/your_rails_app/node_modules/.bin/elm-make
|
112
|
+
chmod +x $HOME/your_rails_app/node_modules/.bin/elm-make
|
113
|
+
```
|
114
|
+
|
115
|
+
## Rake assets:precompile fails. ExecJS::RuntimeError
|
116
|
+
This error occurs because you are trying to minify by terser a pack that's already been minified by Webpacker. To avoid this conflict and prevent appearing of ExecJS::RuntimeError error, you will need to disable uglifier from Rails config:
|
117
|
+
|
118
|
+
```ruby
|
119
|
+
// production.rb
|
120
|
+
# From
|
121
|
+
|
122
|
+
Rails.application.config.assets.js_compressor = :uglifier
|
123
|
+
|
124
|
+
# To
|
125
|
+
|
126
|
+
Rails.application.config.assets.js_compressor = Uglifier.new(harmony: true)
|
127
|
+
|
128
|
+
```
|
129
|
+
|
130
|
+
### Angular: WARNING in ./node_modules/@angular/core/esm5/core.js, Critical dependency: the request of a dependency is an expression
|
131
|
+
|
132
|
+
To silent these warnings, please update `config/webpack/environment.js`
|
133
|
+
|
134
|
+
```js
|
135
|
+
// environment.js
|
136
|
+
const webpack = require('webpack')
|
137
|
+
const { resolve } = require('path')
|
138
|
+
const { environment, config } = require('@rails/webpacker')
|
139
|
+
|
140
|
+
environment.plugins.append('ContextReplacement',
|
141
|
+
new webpack.ContextReplacementPlugin(
|
142
|
+
/angular(\\|\/)core(\\|\/)(@angular|esm5)/,
|
143
|
+
resolve(config.source_path)
|
144
|
+
)
|
145
|
+
)
|
146
|
+
```
|
147
|
+
|
148
|
+
### Compilation Fails Silently
|
149
|
+
|
150
|
+
If compiling is not producing output files and there are no error messages to help troubleshoot. Setting the webpack_compile_output configuration variable to 'true' in webpacker.yml may add some helpful error information to your log file (Rails log/development.log or log/production.log)
|
151
|
+
|
152
|
+
```yml
|
153
|
+
# webpacker.yml
|
154
|
+
default: &default
|
155
|
+
source_path: app/javascript
|
156
|
+
source_entry_path: packs
|
157
|
+
public_root_path: public
|
158
|
+
public_output_path: complaints_packs
|
159
|
+
webpack_compile_output: true
|
160
|
+
```
|
data/docs/v6_upgrade.md
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# To Webpacker v6 from v5
|
2
|
+
|
3
|
+
This guide aims to help you migrating to Webpacker 6. If you are using vanilla Webpacker install then hopefully, the upgrade should be really straightforward.
|
4
|
+
|
5
|
+
## Main differences with v5
|
6
|
+
|
7
|
+
The main goal for Webpacker v6 is to manage the JavaScript in your Rails application with Webpack. This will allows you, for example, to use JavaScript modules, automatic code splitting using multiple entry points, use PostCSS or use [Vue](https://vuejs.org/) or [React](https://reactjs.org/).
|
8
|
+
|
9
|
+
You probably don't want to install Webpacker and Webpack if you only need some JavaScript Sprinkles, Sass integration, images and fonts support.
|
10
|
+
|
11
|
+
### Default integrations
|
12
|
+
|
13
|
+
By default, Webpacker v6 out of the box supports JS and static assets (fonts, images etc.) compilation. Webpacker now detects automatically relevant packages to support more tools.
|
14
|
+
|
15
|
+
See [Integrations](https://github.com/rails/webpacker#integrations) for more information.
|
16
|
+
|
17
|
+
Why? Because most developers don't need to handle CSS, SASS or another tools with Webpack. [Sprockets](https://github.com/rails/sprockets) is probably enough and we don't want to make things harder.
|
18
|
+
|
19
|
+
### Simpler API
|
20
|
+
|
21
|
+
Webpacker is still a wrapper around [Webpack](https://webpack.js.org/) to simplify the integration in your Rails application.
|
22
|
+
|
23
|
+
But we noticed that the [Webpacker v5 configuration](https://github.com/rails/webpacker/blob/5-x-stable/docs/webpack.md) was a bit confusing mostly because Webpack is a complicated beast to manage.
|
24
|
+
|
25
|
+
There are so many different toolchains in JavaScript these days, it would be impossible to create te perfect configuration for everybody. That is also why defaults installers have been removed.
|
26
|
+
|
27
|
+
In order to simplify even more the configuration, the custom API to manage the Webpack configuration has been removed.
|
28
|
+
|
29
|
+
Now you have a straight access to the Webpack configuration and you can change it very easily with webpack-merge. So now, you can refer to the documentation of the tools you want to install it with Webpack. Here is an example with [Vue](https://github.com/rails/webpacker#other-frameworks).
|
30
|
+
|
31
|
+
## How to upgrade to Webpacker v6
|
32
|
+
|
33
|
+
1. If your `source_path` is `app/javascript`, rename it to `app/packs`
|
34
|
+
2. If your `source_entry_path` is `packs`, rename it to `entrypoints`
|
35
|
+
3. Rename `config/webpack` to `config/webpack_old`
|
36
|
+
4. Rename `config/webpacker.yml` to `config/webpacker_old.yml`
|
37
|
+
5. Uninstall the current version of `webpack-dev-server`: `yarn remove webpack-dev-server`
|
38
|
+
6. Upgrade Webpacker
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
# Gemfile
|
42
|
+
gem 'webpacker', '~> 6.0.0.pre.2'
|
43
|
+
```
|
44
|
+
|
45
|
+
```bash
|
46
|
+
bundle install
|
47
|
+
```
|
48
|
+
|
49
|
+
```bash
|
50
|
+
yarn add @rails/webpacker@next
|
51
|
+
```
|
52
|
+
|
53
|
+
```bash
|
54
|
+
bundle exec rails webpacker:install
|
55
|
+
```
|
56
|
+
|
57
|
+
- Change `javascript_packs_with_chunks_tag` and `stylesheet_packs_with_chunks_tag` to `javascript_pack_tag` and
|
58
|
+
`stylesheet_pack_tag`.
|
59
|
+
|
60
|
+
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.
|
61
|
+
|
62
|
+
8. Copy over any custom webpack config from `config/webpack_old`
|
63
|
+
|
64
|
+
- Common code previously called 'environment' changed to 'base'
|
65
|
+
- import `environment` changed name to `webpackConfig`.
|
66
|
+
|
67
|
+
```js
|
68
|
+
// config/webpack/base.js
|
69
|
+
const { webpackConfig, merge } = require('@rails/webpacker')
|
70
|
+
const customConfig = require('./custom')
|
71
|
+
|
72
|
+
module.exports = merge(webpackConfig, customConfig)
|
73
|
+
```
|
74
|
+
|
75
|
+
9. Copy over custom browserlist config from `.browserlistrc` if it exists into the `"browserlist"` key in `package.json` and remove `.browserslistrc`.
|
76
|
+
|
77
|
+
10. `extensions` was removed from the webpacker.yml file. Move custom extensions to
|
78
|
+
your configuration by by merging an object like this. For more details, see docs for
|
79
|
+
[Webpack Configuration](https://github.com/rails/webpacker/blob/master/README.md#webpack-configuration)
|
80
|
+
```js
|
81
|
+
{
|
82
|
+
resolve: {
|
83
|
+
extensions: ['.ts', '.tsx']
|
84
|
+
}
|
85
|
+
}
|
86
|
+
```
|
@@ -1,14 +1,14 @@
|
|
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
|
9
9
|
webpack_compile_output: true
|
10
10
|
|
11
|
-
# Additional paths webpack should
|
11
|
+
# Additional paths webpack should look up modules
|
12
12
|
# ['app/assets', 'engine/foo/app/assets']
|
13
13
|
additional_paths: []
|
14
14
|
|
@@ -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/install/template.rb
CHANGED
@@ -5,10 +5,10 @@ say "Copying webpack core config"
|
|
5
5
|
directory "#{__dir__}/config/webpack", "config/webpack"
|
6
6
|
|
7
7
|
if Dir.exists?(Webpacker.config.source_path)
|
8
|
-
say "The
|
8
|
+
say "The packs app source directory already exists"
|
9
9
|
else
|
10
|
-
say "Creating
|
11
|
-
directory "#{__dir__}/
|
10
|
+
say "Creating packs app source directory"
|
11
|
+
directory "#{__dir__}/packs", Webpacker.config.source_path
|
12
12
|
end
|
13
13
|
|
14
14
|
apply "#{__dir__}/binstubs.rb"
|
@@ -26,13 +26,15 @@ if File.exists?(git_ignore_path)
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
+
results = []
|
30
|
+
|
29
31
|
Dir.chdir(Rails.root) do
|
30
|
-
if Webpacker::VERSION
|
32
|
+
if Webpacker::VERSION.match?(/^[0-9]+\.[0-9]+\.[0-9]+$/)
|
31
33
|
say "Installing all JavaScript dependencies [#{Webpacker::VERSION}]"
|
32
|
-
run
|
34
|
+
results << run("yarn add @rails/webpacker@#{Webpacker::VERSION}")
|
33
35
|
else
|
34
36
|
say "Installing all JavaScript dependencies [from prerelease rails/webpacker]"
|
35
|
-
run
|
37
|
+
results << run("yarn add @rails/webpacker@next")
|
36
38
|
end
|
37
39
|
|
38
40
|
package_json = File.read("#{__dir__}/../../package.json")
|
@@ -41,10 +43,10 @@ Dir.chdir(Rails.root) do
|
|
41
43
|
|
42
44
|
# needed for experimental Yarn 2 support and should not harm Yarn 1
|
43
45
|
say "Installing webpack and webpack-cli as direct dependencies"
|
44
|
-
run
|
46
|
+
results << run("yarn add webpack@#{webpack_version} webpack-cli@#{webpack_cli_version}")
|
45
47
|
|
46
48
|
say "Installing dev server for live reloading"
|
47
|
-
run
|
49
|
+
results << run("yarn add --dev webpack-dev-server @webpack-cli/serve")
|
48
50
|
end
|
49
51
|
|
50
52
|
insert_into_file Rails.root.join("package.json").to_s, before: /\n}\n*$/ do
|
@@ -66,4 +68,9 @@ if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR > 1
|
|
66
68
|
say "policy.connect_src :self, :https, \"http://localhost:3035\", \"ws://localhost:3035\" if Rails.env.development?", :yellow
|
67
69
|
end
|
68
70
|
|
69
|
-
|
71
|
+
if results.all?
|
72
|
+
say "Webpacker successfully installed 🎉 🍰", :green
|
73
|
+
else
|
74
|
+
say "Webpacker installation failed 😭 See above for details.", :red
|
75
|
+
exit 1
|
76
|
+
end
|
@@ -7,9 +7,9 @@ namespace :webpacker do
|
|
7
7
|
prefix = task.name.split(/#|webpacker:binstubs/).first
|
8
8
|
|
9
9
|
if Rails::VERSION::MAJOR >= 5
|
10
|
-
exec "#{RbConfig.ruby} #{bin_path}/rails #{prefix}app:template LOCATION
|
10
|
+
exec "#{RbConfig.ruby} #{bin_path}/rails #{prefix}app:template LOCATION='#{binstubs_template_path}'"
|
11
11
|
else
|
12
|
-
exec "#{RbConfig.ruby} #{bin_path}/rake #{prefix}rails:template LOCATION
|
12
|
+
exec "#{RbConfig.ruby} #{bin_path}/rake #{prefix}rails:template LOCATION='#{binstubs_template_path}'"
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -7,9 +7,9 @@ namespace :webpacker do
|
|
7
7
|
prefix = task.name.split(/#|webpacker:install/).first
|
8
8
|
|
9
9
|
if Rails::VERSION::MAJOR >= 5
|
10
|
-
exec "#{RbConfig.ruby} #{bin_path}/rails #{prefix}app:template LOCATION
|
10
|
+
exec "#{RbConfig.ruby} #{bin_path}/rails #{prefix}app:template LOCATION='#{install_template_path}'"
|
11
11
|
else
|
12
|
-
exec "#{RbConfig.ruby} #{bin_path}/rake #{prefix}rails:template LOCATION
|
12
|
+
exec "#{RbConfig.ruby} #{bin_path}/rake #{prefix}rails:template LOCATION='#{install_template_path}'"
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
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..."
|
@@ -63,11 +63,11 @@ class Webpacker::Configuration
|
|
63
63
|
fetch(:webpack_compile_output)
|
64
64
|
end
|
65
65
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
end
|
66
|
+
def fetch(key)
|
67
|
+
data.fetch(key, defaults[key])
|
68
|
+
end
|
70
69
|
|
70
|
+
private
|
71
71
|
def data
|
72
72
|
@data ||= load
|
73
73
|
end
|
@@ -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]
|