-
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
Dynamic port for webpacker-dev-server #767
Comments
What do you mean by dynamic port? You want to specify a port on runtime i.e. inside your Procfile? You can change port inside |
I don't want to have dev server port hardcoded to |
Can you expand on that? It it adding friction to your development setup in some way? |
@javan We allow passing CLI arguments to binstubs, which can change host and port at runtime but since we also got proxy that's using values from webpacker.yml, CLI arguments are never used: https://github.com/rails/webpacker/blob/master/lib/install/bin/webpack-dev-server.tt#L29 One solution is we set explicit env vars based on these arguments so we can use them as well inside dev server configuration: https://github.com/rails/webpacker/blob/master/lib/webpacker/dev_server.rb#L28 # inside binstubs:
ENV['WEBPACK_DEV_SERVER_PORT'] ||= args('--port') ENV['WEBPACK_DEV_SERVER_PORT'] || fetch(:port) |
I still don't understand why we do that. Why can't the sole source of configuration be |
Personally, I haven't really had any use for this :) but I guess for teams where folks are using different setup, say someone using a Docker container and someone using puma-dev, it would be nice to override the settings at runtime instead of committing conflicting |
I'd prefer that go in --- a/lib/webpacker/dev_server.rb
+++ b/lib/webpacker/dev_server.rb
@@ -25,7 +25,7 @@ class Webpacker::DevServer
end
def port
- fetch(:port)
+ ENV['WEBPACK_DEV_SERVER_PORT'] || fetch(:port)
end |
Yeah, makes sense 👍 |
@javan I and my coworkers usually work with at least two running Rails projects. For each project, there is separate dev server. So with this development setup, we have to hardcode unique port in |
Fixed in #843 |
3.0.2 released 👍 |
Webpacker configuration file is extensively reloaded and it seems there is no straight forward way to dynamically set dev server port, e.g., using Foreman to start Rails and webpacker-dev-server. Any suggestions how to do that?
The text was updated successfully, but these errors were encountered: