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

STRWEB-108 Favicons not injected into html template. #137

Merged
merged 2 commits into from
Mar 5, 2024
Merged

Conversation

JohnC-80
Copy link
Contributor

@JohnC-80 JohnC-80 commented Mar 4, 2024

Problem

Deployed platforms are not displaying their proper favicons as required by branding configuration from stripes-cli.

Approach:

TLDR: Remove usage/plugin-wrapping of speed-measurer-webpack-plugin... our implementation caused plugins to be seen as different types. :(

Favicons are implemented in our build system via the favicons-webpack-plugin. This ever-so-helpful plugin goes the distance by not only generating favicons for us, it also does the dirty(hacky?) work of digging into the separate instance of html-webpack-plugin and injects the appropriate content into the template that you've supplied. In the case of favicons, they end up as a bunch of link[rel="icon"]s in the page's base mark-up. In order to affect the configuration/behavior of html-webpack-plugin, favicons-webpack-plugin hooks into html-webpack-plugin's callback system. html-webpack-plugin has some code that lets other plugins do this - and leans on a JS Weakmap in order to ensure only a single unique set of 'hooks' exist for the plugin instance per compilation. The uniqueness can only be ensured if the objects are the all the of the same type.

Our current code applies the favicon-webpack-plugin via its node API, within the stripes branding plugin. It has to jump through some hoops to gather the supplied branding assets. When we first added esbuild to support transpilation and speed up build-times, we employed speed-measurer-webpack-plugin. This was employed when we build the production webpack configuration by wrapping all of the currently existing plugins with a Proxy class, this causes it to miss the separately added favicons-webpack-plugin - and since it isn't wrapped, it's considered a separate process by html-webpack-plugin when it comes time to resolve its hook callbacks since the proxied webpack Compilations are a different type from standard Compilations. The change here removes the speed-measurer-webpack-plugin and the accompanying plugin-wrapping, so all compilations can be seen as the same type and favicons-webpack-plugin's callback is triggered appropriately so that it can inject the favicons into the HTML Template.
😅 😅 😅

favicons-webpack-plugin sets up other hooks on webpack's own hook system (where it performs actual icon generation) rather than the hooks of another plugin, so those callbacks executed fine.

We could always add speed-measurer-webpack-plugin back later, but it will have to be added to a separate place in the pipeline of our configuration.

Copy link

github-actions bot commented Mar 4, 2024

Jest Unit Test Statistics

0 tests  ±0   0 ✔️ ±0   0s ⏱️ ±0s
0 suites ±0   0 💤 ±0 
0 files   ±0   0 ±0 

Results for commit f4d6f73. ± Comparison against base commit 869d08a.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Mar 4, 2024

BigTest Unit Test Statistics

73 tests  ±0   73 ✔️ ±0   0s ⏱️ ±0s
39 suites ±0     0 💤 ±0 
  1 files   ±0     0 ±0 

Results for commit f4d6f73. ± Comparison against base commit 869d08a.

♻️ This comment has been updated with latest results.

@JohnC-80 JohnC-80 requested review from mkuklis and zburke March 4, 2024 23:23
Copy link
Member

@zburke zburke left a comment

Choose a reason for hiding this comment

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

🙇🙇🙇 🕵️

@JohnC-80 JohnC-80 merged commit e5da675 into master Mar 5, 2024
5 checks passed
zburke pushed a commit that referenced this pull request Mar 7, 2024
* remove usage of speed measurer webpack plugin

* log changes

(cherry picked from commit e5da675)
@zburke zburke deleted the STRWEB-108 branch September 4, 2024 19:17
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