-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Return false in production environments #1179
Conversation
lib/webpacker/dev_server.rb
Outdated
else | ||
Socket.tcp(host, port, connect_timeout: connect_timeout).close | ||
true | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be inverted and check env.development?
instead. We have production-like envs (staging
, beta
) that we want skipped too.
if env.development?
Socket.tcp(host, port, connect_timeout: connect_timeout).close
true
else
false
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All production like environments will have NODE_ENV=production
and that will evaluate env.production?
to true
so the logic will work for all production like environments as long as NODE_ENV is set. Would that work?
def env
(ENV["NODE_ENV"].presence_in(available_environments) ||
Rails.env.presence_in(available_environments) ||
"production".freeze).inquiry
end
Reason for scoping to production was that, in case someone wants to use dev server in test environment. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we can check if dev_server
is configured? Since, by default, it's only in development:
webpacker/lib/install/config/webpacker.yml
Lines 33 to 38 in 6695445
development: | |
<<: *default | |
compile: true | |
# Reference: https://webpack.js.org/configuration/dev-server/ | |
dev_server: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh yes, good idea 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 👍
* 'master' of https://github.com/rails/webpacker: (21 commits) Update Ruby versions on Travis CI (rails#1230) Make rubocop happy Fix asset helper for non-css assets in hmr mode CSP warning for Rails 5.2 use 2 spaces for indentation in template injection Update README.md (rails#1198) Remove duplicate yarn-error.log (rails#1197) 3.2.1 Revert file loader (rails#1196) Update default extensions and move to installer (rails#1181) Gitignore (rails#1195) Update uglify plugin (rails#1194) Fixes Vue root instance initialization (rails#1187) Return false in production environments (rails#1179) Fix url loader doc[ci skip] (rails#1183) Use inject_into_file to support rails 4.2 Update gems and npm deps (rails#1180) asset_pack_path + HMR fix; Closes rails#1171 (rails#1172) enhance CHANGELOG.md (rails#1170) CI against Ruby 2.5.0 ...
``` Error: PagesControllerTest#test_it_mounts_components_from_the_dev_server: RuntimeError: Failed to start dev server /home/travis/build/reactjs/react-rails/test/support/webpacker_helpers.rb:65:in `with_dev_server' /home/travis/build/reactjs/react-rails/test/react/rails/pages_controller_test.rb:32:in `block (2 levels) in <class:PagesControllerTest>' ``` Related to rails/webpacker#1179
``` Error: PagesControllerTest#test_it_mounts_components_from_the_dev_server: RuntimeError: Failed to start dev server /home/travis/build/reactjs/react-rails/test/support/webpacker_helpers.rb:65:in `with_dev_server' /home/travis/build/reactjs/react-rails/test/react/rails/pages_controller_test.rb:32:in `block (2 levels) in <class:PagesControllerTest>' ``` Related to rails/webpacker#1179
``` Error: PagesControllerTest#test_it_mounts_components_from_the_dev_server: RuntimeError: Failed to start dev server /home/travis/build/reactjs/react-rails/test/support/webpacker_helpers.rb:65:in `with_dev_server' /home/travis/build/reactjs/react-rails/test/react/rails/pages_controller_test.rb:32:in `block (2 levels) in <class:PagesControllerTest>' ``` Related to rails/webpacker#1179
``` Error: PagesControllerTest#test_it_mounts_components_from_the_dev_server: RuntimeError: Failed to start dev server /home/travis/build/reactjs/react-rails/test/support/webpacker_helpers.rb:65:in `with_dev_server' /home/travis/build/reactjs/react-rails/test/react/rails/pages_controller_test.rb:32:in `block (2 levels) in <class:PagesControllerTest>' ``` Related to rails/webpacker#1179
Fixes #1173
This PR enables bypassing of dev server check in production environment since the assets are precompiled in production environments.