-
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
Enable devserver proxy for custom environments #1415
Enable devserver proxy for custom environments #1415
Conversation
@@ -60,6 +60,6 @@ def fetch(key) | |||
end | |||
|
|||
def defaults | |||
config.send(:defaults)[:dev_server] | |||
config.send(:defaults)[: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.
what about config.dig(:defaults, :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.
config is not a hash, but a Webpacker::Configuration which has a 'defaults' private method.
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.
oh i see
lib/webpacker/railtie.rb
Outdated
if Webpacker.config.dev_server.present? | ||
insert_middleware = Webpacker.config.dev_server.present? rescue nil | ||
insert_middleware ||= false | ||
if insert_middleware |
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.
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.
you're right ! thanks
ed6743a
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.
Actually if Webpacker.config.dev_server
will be fine, because call present?
to an object is equal to check the object is not nil
besides, in this case, this statement would not raise any error (nil.present?
will got false
), so no need to rescue.
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.
Actually Webpacker.config is a Webpacker::Configuration object ; and the call to Webpacker.config.dev_server.present? leads to call the "load" method of Webpacker.config instance.
And this can fail for some reasons : bad config, no config file... This happens in unit tests environments for projects which depend on webpacker, for exemple.
I think that devserver proxy middleware initializer should not raise error in this case, but just skip.
thanks @mchalandon |
It should be usefull to enable the devserver proxy for custom environements ; for projects with severall development environements.