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

Enable devserver proxy for custom environments #1415

Merged

Conversation

mchalandon
Copy link
Contributor

It should be usefull to enable the devserver proxy for custom environements ; for projects with severall development environements.

@@ -60,6 +60,6 @@ def fetch(key)
end

def defaults
config.send(:defaults)[:dev_server]
config.send(:defaults)[:dev_server] || {}
Copy link
Contributor

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)?

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh i see

if Webpacker.config.dev_server.present?
insert_middleware = Webpacker.config.dev_server.present? rescue nil
insert_middleware ||= false
if insert_middleware
Copy link
Contributor

Choose a reason for hiding this comment

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

nil is equal to false in if statement
image

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor Author

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.

mchalandon added 3 commits April 10, 2018 12:01
…zation"

This reverts commit e1289b3.

not needed anymore since commit 14c305b ensures that webpacker.proxy initialization won't fail
@gauravtiwari gauravtiwari merged commit 463c6f7 into rails:master Apr 16, 2018
@gauravtiwari
Copy link
Member

thanks @mchalandon

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.

3 participants