Skip to content
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

Merged
merged 4 commits into from
Jan 15, 2018
Merged

Return false in production environments #1179

merged 4 commits into from
Jan 15, 2018

Conversation

gauravtiwari
Copy link
Member

Fixes #1173

This PR enables bypassing of dev server check in production environment since the assets are precompiled in production environments.

else
Socket.tcp(host, port, connect_timeout: connect_timeout).close
true
end
Copy link
Contributor

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

Copy link
Member Author

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?

Copy link
Contributor

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:

development:
<<: *default
compile: true
# Reference: https://webpack.js.org/configuration/dev-server/
dev_server:

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh yes, good idea 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 👍

@gauravtiwari gauravtiwari merged commit 8429874 into master Jan 15, 2018
@gauravtiwari gauravtiwari deleted the dev-server branch January 15, 2018 09:10
kawikadkekahuna added a commit to wealthfit/webpacker that referenced this pull request Jan 29, 2018
* '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
  ...
ttanimichi added a commit to reactjs/react-rails that referenced this pull request Aug 6, 2018
```
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
hardcarry1995 pushed a commit to hardcarry1995/react-rails that referenced this pull request Jan 9, 2023
```
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
goldapple911 added a commit to goldapple911/react-rails that referenced this pull request Aug 15, 2023
```
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants