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

Incorporate linkPrefix into webpack's publicPath #502

Merged
merged 1 commit into from
Oct 25, 2016

Conversation

mojodna
Copy link
Contributor

@mojodna mojodna commented Oct 14, 2016

This correctly references asset paths, e.g. FontAwesome, when static sites are targeted at sub-paths.

Prior to this, FontAwesome asset paths would point at the site root.

@KyleAMathews
Copy link
Contributor

@mojodna does this work? @tribou tried this before and ran into problems... #393

Also for a PR like this, you need to check if prefixing links is active similar to what I've done on the 1.0 branch

publicPath: program.prefixLinks ? `${siteDB().get(`config`).linkPrefix}/` : `/`,

@mojodna
Copy link
Contributor Author

mojodna commented Oct 17, 2016

Err, maybe not. Sounds like I fell into the same trap. Here's my app-land workaround: https://github.com/mojodna/posm-admin-ii/blob/master/gatsby-node.js#L16-L22

@KyleAMathews
Copy link
Contributor

Oh nice! That's perfect. Would love it if you pushed that into the PR. This is a fairly common problem right now so it'd be good to get it fixed.

@mojodna
Copy link
Contributor Author

mojodna commented Oct 17, 2016

Maybe it belongs in the starter packs instead, or in the meantime?

Might be worth documenting it (though maybe the issues suffice), since I expect others may also spend hours trying to understand why things aren't working before realizing that it's actually a webpack configuration problem.

@KyleAMathews
Copy link
Contributor

Why not in core? AFAIK the webpack publicPath should always be / or /my-site-prefix/.

@mojodna
Copy link
Contributor Author

mojodna commented Oct 17, 2016

Oh, core would be ideal, but if it's not feasible...

I'll take another whack at this, but it'll be a few days before I'm able.

@KyleAMathews
Copy link
Contributor

Yeah it should totally be possible. The only problem with your's and @tribou's PR is requiring config.toml doesn't work as that's a Webpack thing. If you do what you did in your site it'll work just fine.

This correctly references asset paths, e.g. FontAwesome, when static
sites are targeted at sub-paths.
@mojodna
Copy link
Contributor Author

mojodna commented Oct 25, 2016

@KyleAMathews I just pushed a replacement commit that uses toml to load the config and works when linked into a project that uses gatsby.

@KyleAMathews
Copy link
Contributor

Awesome thanks! Will add this to a release in a jiffy.

@jlengstorf
Copy link
Contributor

Hiya @mojodna! 👋

This is definitely late, but on behalf of the entire Gatsby community, I wanted to say thank you for being here.

Gatsby is built by awesome people like you. Let us say “thanks” in two ways:

  1. We’d like to send you some Gatsby swag. As a token of our appreciation, you can go to the Gatsby Swag Store and log in with your GitHub account to get a coupon code good for one free piece of swag. (We’ve got t-shirts and hats, plus some socks that are really razzing our berries right now.)
  2. If you’re not already part of it, we just invited you to join the Gatsby organization on GitHub. This will add you to our team of maintainers. You’ll receive an email shortly asking you to confirm. By joining the team, you’ll be able to label issues, review pull requests, and merge approved pull requests.

If you have questions, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’.

Thanks again! 💪💜

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