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

fix(gatsby-plugin-manifest): fixes icons not getting asset prefix #20142

Merged
merged 7 commits into from
Jan 27, 2020

Conversation

moonmeister
Copy link
Contributor

Description

Modifies any path provided for a manifest icon to be prefixed with appropriate path or asset prefix.

Currently this affects all provided paths including those from manual, hybrid, and automatic modes. I think this makes the most sense, not sure if there will be any edge cases that need a work around.

This change could potentially create a breaking change for people using asset prefix in manual/hybrid mode who have provided full paths to work around the plugin not handling this for them,.

Documentation

I haven't written any, Do we think we should document this change in behavior?

Related Issues

Fixes: #18497

@moonmeister moonmeister added type: bug An issue or pull request relating to a bug in Gatsby topic: plugins labels Dec 16, 2019
@moonmeister moonmeister requested a review from a team as a code owner December 16, 2019 03:14
@freiksenet freiksenet added the bot: merge on green Gatsbot will merge these PRs automatically when all tests passes label Dec 17, 2019
Copy link
Contributor

@freiksenet freiksenet left a comment

Choose a reason for hiding this comment

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

Some end-to-end tests break on ASSET_PREFIX, I wonder if you could fix them.

@moonmeister
Copy link
Contributor Author

moonmeister commented Dec 17, 2019

Some end-to-end tests break on ASSET_PREFIX, I wonder if you could fix them.

So what's the fix? Do i just need to set an empty string if the global isn't already set? If that's the case it seems like this should be handled by gatsby-link? That way every place that uses this doesn't have to check for an non-existent global? Or should the config handler be setting __PATH_PREFIX__ global no matter whether there is something in my gatsby-config? It looks like I could also use the modules from the API, would that be a fix?

What's the "correct" path here? Thanks.

@wardpeet
Copy link
Contributor

withPrefix helpers are only accessible in webpack land so gatsby-ssr & gatsby-browser.

In gatsby node you'll have to use the basePath property that is given to you by onPostBootstrap. You only need to fix the src urls inside manifest.webmanifest, not while generating the files.

exports.onPostBootstrap = async (
  { reporter, parentSpan, basePath },
  { localize, ...manifest }
) => {
// ...
await makeManifest(cache, reporter, manifest, false, basePath)

@moonmeister
Copy link
Contributor Author

@wardpeet Thanks for the info, reverted my earlier changes and redid them, everything seems much easier now. From my testing this doesn't do "assetPrefix"

  • What am I missing to prefix the assetPrefix?
  • What do you think about applying this to the start_url option in the manifest as well?

Thanks.

@wardpeet
Copy link
Contributor

What am I missing to prefix the assetPrefix?

I'll check this out in a bit.

What do you think about applying this to the start_url option in the manifest as well?

That would be great! If you could do that.

@ehannes
Copy link

ehannes commented Jan 23, 2020

Any news on this @moonmeister?

@moonmeister
Copy link
Contributor Author

Think I was waiting on @wardpeet

@wardpeet
Copy link
Contributor

My bad, I flagged it to check this out tomorrow morning. I'm really sorry to keep you waiting

@wardpeet wardpeet self-assigned this Jan 23, 2020
@wardpeet wardpeet removed the bot: merge on green Gatsbot will merge these PRs automatically when all tests passes label Jan 25, 2020
@wardpeet
Copy link
Contributor

i've added tests and fixed a small bug with start_url. It should all be operational now and working. I'll merge on monday, thanks @moonmeister for your work! 🙏

Copy link
Contributor

@wardpeet wardpeet left a comment

Choose a reason for hiding this comment

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

Everything is green, let's do this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Broken icon links in Manifest file when using assetPrefix
4 participants