Skip to content

Commit 6614a4f

Browse files
authored
bin/webpack[-dev-server] to webpacker[-dev-server] (#3252)
Renamed `/bin/webpack` to `/bin/webpacker` and `/bin/webpack-dev-server` to `bin/webpacker-dev-server` to avoid confusion with underlying webpack executables.
1 parent 34942aa commit 6614a4f

19 files changed

+39
-36
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ environment.loaders.append('nodeModules', nodeModules)
2222
- Update static files path to from `media/` to `static/`.
2323

2424
### Breaking changes
25+
- Renamed `/bin/webpack` to `/bin/webpacker` and `/bin/webpack-dev-server` to `bin/webpacker-dev-server` to avoid confusion with underlying webpack executables.
2526
- Removed integration installers
2627
- Splitchunks enabled by default
2728
- CSS extraction enabled by default, except when devServer is configured and running

README.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -206,44 +206,44 @@ Note, if you are using server-side rendering of JavaScript with dynamic code-spl
206206

207207
### Development
208208

209-
Webpacker ships with two binstubs: `./bin/webpack` and `./bin/webpack-dev-server`. Both are thin wrappers around the standard `webpack.js` and `webpack-dev-server.js` executables to ensure that the right configuration files and environmental variables are loaded based on your environment.
209+
Webpacker ships with two binstubs: `./bin/webpacker` and `./bin/webpacker-dev-server`. Both are thin wrappers around the standard `webpack.js` and `webpack-dev-server.js` executables to ensure that the right configuration files and environmental variables are loaded based on your environment.
210210

211-
In development, Webpacker compiles on demand rather than upfront by default. This happens when you refer to any of the pack assets using the Webpacker helper methods. This means that you don't have to run any separate processes. Compilation errors are logged to the standard Rails log. However, this auto-compilation happens when a web request is made that requires an updated webpack build, not when files change. Thus, that can be painfully slow for front-end development in this default way. Instead, you should either run the `bin/webpack --watch` or run `./bin/webpack-dev-server`
211+
In development, Webpacker compiles on demand rather than upfront by default. This happens when you refer to any of the pack assets using the Webpacker helper methods. This means that you don't have to run any separate processes. Compilation errors are logged to the standard Rails log. However, this auto-compilation happens when a web request is made that requires an updated webpack build, not when files change. Thus, that can be painfully slow for front-end development in this default way. Instead, you should either run the `bin/webpacker --watch` or run `./bin/webpacker-dev-server`
212212

213-
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 in a terminal separate from `bundle exec rails s`. This process will watch for changes in the relevant files, defined by `webpacker.yml` configuration settings for `source_path`, `source_entry_path`, and `additional_paths`, and it will then automatically reload the browser to match. This feature is also known as [Hot Module Replacement](https://webpack.js.org/concepts/hot-module-replacement/).
213+
If you want to use live code reloading, or you have enough JavaScript that on-demand compilation is too slow, you'll need to run `./bin/webpacker-dev-server` or `ruby ./bin/webpacker-dev-server`. Windows users will need to run these commands in a terminal separate from `bundle exec rails s`. This process will watch for changes in the relevant files, defined by `webpacker.yml` configuration settings for `source_path`, `source_entry_path`, and `additional_paths`, and it will then automatically reload the browser to match. This feature is also known as [Hot Module Replacement](https://webpack.js.org/concepts/hot-module-replacement/).
214214

215215
```bash
216216
# webpack dev server
217-
./bin/webpack-dev-server
217+
./bin/webpacker-dev-server
218218
219219
# watcher
220-
./bin/webpack --watch --progress
220+
./bin/webpacker --watch --progress
221221
222222
# standalone build
223-
./bin/webpack --progress
223+
./bin/webpacker --progress
224224
225225
# Help
226-
./bin/webpack help
226+
./bin/webpacker help
227227
228228
# Version
229-
./bin/webpack version
229+
./bin/webpacker version
230230
231231
# Info
232-
./bin/webpack info
232+
./bin/webpacker info
233233
```
234234

235235
Once you start this webpack development server, Webpacker will automatically start proxying all webpack asset requests to this server. When you stop this server, Rails will detect that it's not running and Rails will revert back to on-demand compilation _if_ you have the `compile` option set to true in your `config/webpacker.yml`
236236

237237
You can use environment variables as options supported by [webpack-dev-server](https://webpack.js.org/configuration/dev-server/) in the form `WEBPACKER_DEV_SERVER_<OPTION>`. Please note that these environmental variables will always take precedence over the ones already set in the configuration file, and that the _same_ environmental variables must be available to the `rails server` process.
238238

239239
```bash
240-
WEBPACKER_DEV_SERVER_HOST=example.com WEBPACKER_DEV_SERVER_INLINE=true WEBPACKER_DEV_SERVER_HOT=false ./bin/webpack-dev-server
240+
WEBPACKER_DEV_SERVER_HOST=example.com WEBPACKER_DEV_SERVER_INLINE=true WEBPACKER_DEV_SERVER_HOT=false ./bin/webpacker-dev-server
241241
```
242242

243-
By default, the webpack dev server listens on `localhost` in development for security purposes. However, if you want your app to be available over local LAN IP or a VM instance like vagrant, you can set the `host` when running `./bin/webpack-dev-server` binstub:
243+
By default, the webpack dev server listens on `localhost` in development for security purposes. However, if you want your app to be available over local LAN IP or a VM instance like vagrant, you can set the `host` when running `./bin/webpacker-dev-server` binstub:
244244

245245
```bash
246-
WEBPACKER_DEV_SERVER_HOST=0.0.0.0 ./bin/webpack-dev-server
246+
WEBPACKER_DEV_SERVER_HOST=0.0.0.0 ./bin/webpacker-dev-server
247247
```
248248

249249
**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:
@@ -534,8 +534,8 @@ Please note, binstubs compiles in development mode however rake tasks compiles i
534534

535535
```bash
536536
# Compiles in development mode unless NODE_ENV is specified, per the binstub source
537-
./bin/webpack
538-
./bin/webpack-dev-server
537+
./bin/webpacker
538+
./bin/webpacker-dev-server
539539
540540
# Compiles in production mode by default unless NODE_ENV is specified, per `lib/tasks/webpacker/compile.rake`
541541
bundle exec rails assets:precompile

docs/troubleshooting.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
1. Read the error message carefully. The error message will tell you the precise key value
66
that is not matching what Webpack expects.
77

8-
2. Put a `debugger` statement in your Webpack configuration and run `bin/webpack --debug-webpacker`.
8+
2. Put a `debugger` statement in your Webpack configuration and run `bin/webpacker --debug-webpacker`.
99
If you have a node debugger installed, you'll see the Chrome debugger for your webpack
1010
config. For example, install the Chrome extension
1111
[NiM](https://chrome.google.com/webstore/detail/nodejs-v8-inspector-manag/gnhhdgbaldcilmgcpfddgdbkhjohddkj) and
1212
set the option for the dev tools to open automatically. Or put `chrome://inspect` in the URL bar.
1313
For more details on debugging, see the official
1414
[Webpack docs on debugging](https://webpack.js.org/contribute/debugging/#devtools)
1515

16-
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.
16+
3. Any arguments that you add to bin/webpacker 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.
1717

1818
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`
1919

@@ -50,7 +50,7 @@ Webpacker uses a `manifest.json` file to keep track of packs in all environments
5050
however since this file is generated after packs are compiled by webpack. So,
5151
if you load a view in browser whilst webpack is compiling you will get this error.
5252
Therefore, make sure webpack
53-
(i.e `./bin/webpack-dev-server`) is running and has
53+
(i.e `./bin/webpacker-dev-server`) is running and has
5454
completed the compilation successfully before loading a view.
5555

5656

@@ -79,7 +79,7 @@ bundle config --delete bin
7979
## Running webpack on Windows
8080

8181
If you are running webpack on Windows, your command shell may not be able to interpret the preferred interpreter
82-
for the scripts generated in `bin/webpack` and `bin/webpack-dev-server`. Instead you'll want to run the scripts
82+
for the scripts generated in `bin/webpacker` and `bin/webpacker-dev-server`. Instead you'll want to run the scripts
8383
manually with Ruby:
8484

8585
```
@@ -89,7 +89,7 @@ C:\path>ruby bin\webpack-dev-server
8989

9090
## Invalid configuration object. webpack has been initialised using a configuration object that does not match the API schema.
9191

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`.
92+
If you receive this error when running `$ ./bin/webpacker-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`.
9393

9494
## Running Elm on Continuous Integration (CI) services such as CircleCI, CodeShip, Travis CI
9595

docs/v6_upgrade.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,16 @@ See customization example the [Customizing Babel Config](./docs/customizing_babe
104104

105105
16. Review the new default's changes to `webpacker.yml` and `config/webpack`. Consider each suggested change carefully, especially the change to have your `source_entry_path` be at the top level of your `source_path`.
106106

107-
17. Make sure that you can run `bin/webpack` without errors.
107+
17. Make sure that you can run `bin/webpacker` without errors.
108108

109109
18. Try running `RAILS_ENV=production bin/rails assets:precompile`. If all goes well, don't forget to clean the generated assets with `bin/rails assets:clobber`.
110110

111111
19. Run `yarn add webpack-dev-server` if those are not already in your dev dependencies. Make sure you're using v4+.
112112

113113
20. Try your app!
114114

115+
21. Update any scripts that called `/bin/webpack` or `bin/webpack-dev-server` to `/bin/webpacker` or `bin/webpacker-dev-server`
116+
115117
## Examples of v5 to v6
116118

117119
1. [React on Rails Project with HMR and SSR](https://github.com/shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh/compare/webpacker-5.x...master)
File renamed without changes.

lib/install/config/webpacker.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Note: You must restart bin/webpack-dev-server for changes to take effect
1+
# Note: You must restart bin/webpacker-dev-server for changes to take effect
22

33
default: &default
44
source_path: app/javascript

lib/tasks/webpacker.rake

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ tasks = {
66
"webpacker:clobber" => "Removes the webpack compiled output directory",
77
"webpacker:check_node" => "Verifies if Node.js is installed",
88
"webpacker:check_yarn" => "Verifies if Yarn is installed",
9-
"webpacker:check_binstubs" => "Verifies that bin/webpack is present",
9+
"webpacker:check_binstubs" => "Verifies that bin/webpacker is present",
1010
"webpacker:binstubs" => "Installs Webpacker binstubs in this application",
1111
"webpacker:verify_install" => "Verifies if Webpacker is installed",
1212
"webpacker:yarn_install" => "Support for older Rails versions. Install all JavaScript dependencies as specified via Yarn"

lib/tasks/webpacker/check_binstubs.rake

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
namespace :webpacker do
2-
desc "Verifies that bin/webpack is present"
2+
desc "Verifies that bin/webpacker is present"
33
task :check_binstubs do
4-
unless File.exist?(Rails.root.join("bin/webpack"))
4+
unless File.exist?(Rails.root.join("bin/webpacker"))
55
$stderr.puts "webpack binstub not found.\n"\
66
"Have you run rails webpacker:install ?\n"\
7-
"Make sure the bin directory and bin/webpack are not included in .gitignore\n"\
7+
"Make sure the bin directory and bin/webpacker are not included in .gitignore\n"\
88
"Exiting!"
99
exit!
1010
end

lib/tasks/webpacker/info.rake

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ namespace :webpacker do
1313
$stdout.puts "\n"
1414
$stdout.puts "@rails/webpacker: \n#{`npm list @rails/webpacker version`}"
1515

16-
$stdout.puts "Is bin/webpack present?: #{File.exist? 'bin/webpack'}"
17-
$stdout.puts "Is bin/webpack-dev-server present?: #{File.exist? 'bin/webpack-dev-server'}"
16+
$stdout.puts "Is bin/webpacker present?: #{File.exist? 'bin/webpacker'}"
17+
$stdout.puts "Is bin/webpacker-dev-server present?: #{File.exist? 'bin/webpacker-dev-server'}"
1818
$stdout.puts "Is bin/yarn present?: #{File.exist? 'bin/yarn'}"
1919
end
2020
end

lib/webpacker/compiler.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def record_compilation_digest
6666
end
6767

6868
def optionalRubyRunner
69-
bin_webpack_path = config.root_path.join("bin/webpack")
69+
bin_webpack_path = config.root_path.join("bin/webpacker")
7070
first_line = File.readlines(bin_webpack_path).first.chomp
7171
/ruby/.match?(first_line) ? RbConfig.ruby : ""
7272
end
@@ -76,7 +76,7 @@ def run_webpack
7676

7777
stdout, stderr, status = Open3.capture3(
7878
webpack_env,
79-
"#{optionalRubyRunner} ./bin/webpack",
79+
"#{optionalRubyRunner} ./bin/webpacker",
8080
chdir: File.expand_path(config.root_path)
8181
)
8282

lib/webpacker/manifest.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def missing_file_from_manifest_error(bundle_name)
108108
1. You forgot to install node packages (try `yarn install`) or are running an incompatible version of Node
109109
2. Your app has code with a non-standard extension (like a `.jsx` file) but the extension is not in the `extensions` config in `config/webpacker.yml`
110110
3. You have set compile: false (see `config/webpacker.yml`) for this environment
111-
(unless you are using the `webpack -w` or the webpack-dev-server, in which case maybe you aren't running the dev server in the background?)
111+
(unless you are using the `bin/webpacker -w` or the `bin/webpacker-dev-server`, in which case maybe you aren't running the dev server in the background?)
112112
4. webpack has not yet re-run to reflect updates.
113113
5. You have misconfigured Webpacker's `config/webpacker.yml` file.
114114
6. Your webpack configuration is not creating a manifest.

test/engine_rake_tasks_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ def mounted_app_path
2626

2727
def webpack_binstub_paths
2828
[
29-
"#{mounted_app_path}/test/dummy/bin/webpack",
30-
"#{mounted_app_path}/test/dummy/bin/webpack-dev-server",
29+
"#{mounted_app_path}/test/dummy/bin/webpacker",
30+
"#{mounted_app_path}/test/dummy/bin/webpacker-dev-server",
3131
]
3232
end
3333

test/mounted_app/test/dummy/config/webpacker.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Note: You must restart bin/webpack-dev-server for changes to take effect
1+
# Note: You must restart bin/webpacker-dev-server for changes to take effect
22

33
default: &default
44
source_path: app/packs
File renamed without changes.

test/test_app/config/webpacker.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Note: You must restart bin/webpack-dev-server for changes to take effect
1+
# Note: You must restart bin/webpacker-dev-server for changes to take effect
22

33
default: &default
44
source_path: app/packs

test/test_app/config/webpacker_other_location.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Note: You must restart bin/webpack-dev-server for changes to take effect
1+
# Note: You must restart bin/webpacker-dev-server for changes to take effect
22

33
default: &default
44
source_path: app/packs

test/test_app/config/webpacker_public_root.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Note: You must restart bin/webpack-dev-server for changes to take effect
1+
# Note: You must restart bin/webpacker-dev-server for changes to take effect
22

33
default: &default
44
public_root_path: ../public

0 commit comments

Comments
 (0)