Skip to content

Conversation

hyshka
Copy link
Contributor

@hyshka hyshka commented May 26, 2022

This is untested code but I am wondering if there is an appetite for a feature like this which would allow you to set skip_common_chunks per config without having to add skip_common_chunks=True to all of your render_bundle template tags. I realize this is likely an edge case but it would be helpful to have it as a setting instead of solely a template tag option.

You can now specify a SKIP_COMMON_CHUNKS setting globally for each Webpack configuration. This will perform the same skip_common_chunks logic from the render_bundle template tag without having to add a parameter to every tag.

To maintain backwards compatibility we default to 'False' and allow common chunks to be rendered to the HTML document as script tags. In the future, it will be easy to change this default behaviour if desired.

I've added test coverage to ensure that the global setting can be overridden by the existing template tag parameter and that we maintain backward compatibility.

@fjsj
Copy link
Member

fjsj commented May 27, 2022

Thanks. Please feel free to add this global setting behavior with tests too. Please test if the skip_common_chunks arg properly overrides the settings in all cases.
In near future, we can make this the default behavior, as it is on Webpack's own html-webpack-plugin.

@hyshka
Copy link
Contributor Author

hyshka commented May 30, 2022

Ok, that sounds great, I will put something together!

@hyshka hyshka force-pushed the add-skip-common-chunks-setting branch from 7b4292c to 4aa0ee3 Compare May 30, 2022 22:01
@hyshka hyshka changed the title [RFC] Add a setting to determine skip common chunks behaviour Add a setting to configure skip common chunks behaviour globally May 31, 2022
@hyshka
Copy link
Contributor Author

hyshka commented May 31, 2022

@fjsj I've reworked this PR, let me know what you think of this approach.

You can now specify a 'SKIP_COMMON_CHUNKS' setting globally for each
Webpack configuration. This will perform the same 'skip_common_chunks'
logic from the 'render_bundle' template tag without having to add
a parameter to every tag.

To maintain backwards compatibility we default to 'False' and allow
common chunks to be rendered to the HTML document as script tags. In the
future, it will be easy to change this default behaviour if desired.

I've added test coverage to ensure that the global setting can be
override by the existing template tag parameter and that we maintain
backwards compatibility.
@hyshka hyshka force-pushed the add-skip-common-chunks-setting branch from 56aa00f to 7498eb6 Compare May 31, 2022 15:18
@hyshka
Copy link
Contributor Author

hyshka commented Jun 13, 2022

@fjsj Just wanted to bump this since it's been a couple of weeks.

@fjsj
Copy link
Member

fjsj commented Jun 16, 2022

Thanks, I'll be checking this in the next couple of days.

@fjsj fjsj merged commit b4ba26a into django-webpack:master Jun 20, 2022
@hyshka hyshka deleted the add-skip-common-chunks-setting branch June 20, 2022 14:44
@fjsj
Copy link
Member

fjsj commented Jun 20, 2022

Released on 1.6.0. Thanks!

@hyshka
Copy link
Contributor Author

hyshka commented Jun 20, 2022

Thanks so much @fjsj!

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