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

Update webpack dev server configuration #276

Merged
merged 14 commits into from
Apr 15, 2023

Conversation

ahangarha
Copy link
Contributor

@ahangarha ahangarha commented Apr 4, 2023

Summary

This PR adds/modifies the dev-server config based on the standard Webpack dev-server configuration.

Pull Request checklist

  • Add/update test to cover these changes
  • Update documentation
  • Update CHANGELOG file

Other Information

closes #217

@ahangarha ahangarha changed the base branch from master to shakapacker-v7 April 4, 2023 13:01
@justin808 justin808 requested a review from tomdracz April 6, 2023 19:57
@ahangarha ahangarha force-pushed the update-webpack-dev-server-configuration branch from 5c68c3a to 21cf806 Compare April 9, 2023 17:31
@ahangarha ahangarha force-pushed the update-webpack-dev-server-configuration branch from 21cf806 to 5e77f91 Compare April 9, 2023 17:32
@ahangarha ahangarha changed the title WIP - Update webpack dev server configuration Update webpack dev server configuration Apr 10, 2023
@ahangarha ahangarha marked this pull request as ready for review April 10, 2023 11:40
lib/install/config/shakapacker.yml Outdated Show resolved Hide resolved
package/environments/development.js Outdated Show resolved Hide resolved
CHANGELOG.md Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
package/environments/development.js Outdated Show resolved Hide resolved
package/environments/development.js Outdated Show resolved Hide resolved
Copy link
Member

@justin808 justin808 left a comment

Choose a reason for hiding this comment

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

Please let me know when ready to merge.

lib/shakapacker/dev_server.rb Outdated Show resolved Hide resolved
@ahangarha
Copy link
Contributor Author

ahangarha commented Apr 11, 2023

@justin808
I think all the code related to modifying dev_server configuration should move out from development.js into dev_server.js.

Am I right?

The logic for mapping keys in the shakapacker.yml file is straightforward: if
a key is specific to webpack, it will be mapped to camelCase, otherwise, the
key will remain as is. This means that any other key that is not specific to
webpack (such as random_key) will remain accessible in its original form.
@ahangarha
Copy link
Contributor Author

I have made some refactoring.

  • I moved all the code related to processing devServer entries into dev_server.js.
  • There, after setting a few particular entries, I map all the entries from the original config file into devServer object. There, I map all the Webpack-specific keys into keys in camelCase format. Any other Webpack non-specific keys get copied without any change.

@ahangarha ahangarha requested a review from justin808 April 12, 2023 16:41
Copy link
Member

@justin808 justin808 left a comment

Choose a reason for hiding this comment

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

lgtm

@justin808 justin808 merged commit 6c507a9 into shakapacker-v7 Apr 15, 2023
@justin808 justin808 deleted the update-webpack-dev-server-configuration branch April 15, 2023 02:47
ahangarha added a commit that referenced this pull request Apr 19, 2023
* Set allowed_host to auto as per webpack recommendation
* Use server: http instead of https: false
* Remove server entry from config and improve value detection
* Add support for hash value for server entry
* Update dev_server_runner to use protocol
* Add server or https entry conditionally
* Add support for other standard devServer config

In this commit, I add support for those keys written in snake-case to be
added to the configurations in camel-case format, if they are set.

The logic for mapping keys in the shakapacker.yml file is straightforward: if
a key is specific to webpack, it will be mapped to camelCase; otherwise, the
key will remain as is. Any other key not specific to
webpack (such as random_key) will remain accessible in its original form.

* Run the logic only in a dev environment
* Set specific exception type for rescue
ahangarha added a commit that referenced this pull request Apr 27, 2023
* Rename Webpacker instances to shakapacker (#245)
* Add backward compatibility (#252)
* Update docs for spelling change (#263)
* Fix backward compatibility for setting WEBPACKER_CONFIG in webpack.config.js (#266)
* Remove redundant code for enhancing precompile task (#270)
* Update webpack dev server configuration (#276)
* Stop stripping top level dirs (#283)
* Improve source_entry_path robustness (#284)

---------

Co-authored-by: Tom Dracz <[email protected]>
justin808 added a commit that referenced this pull request May 8, 2023
)

* Changed default webpackConfig to be either a function that returns a new object or the a global object
* generateWebpackConfig => new object
* globalMutableWebpackConfig => old, mutable object 
* doc updates
* Fixed broken webpack-dev-server
* Improved handling of all available webpack-dev-server keys done in #276 

---------

Co-authored-by: Mostafa Ahangarha <[email protected]>
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.

Update webpack-dev-server configuration
2 participants