Gatsby: Build is broken if you define pathPrefix, but don't use the --prefix-paths flag.

Created on 1 Nov 2017  Â·  9Comments  Â·  Source: gatsbyjs/gatsby

Issue: if I define pathPrefix, then my build is broken if I don't use the --prefix-paths flag. Everything works fine if I simply run gatsby develop

Expected:
I use pathPrefix because i upload to ghpages, but I still test the build locally, and I will occasionally use a staging server that does not need a prefix. So run gatsby build without the flag, and expect to be able to use gatsby serve without any issues.

What actually happens:
I tested two different gatsby projects, and both had issues when I defined a pathPrefix, but did not use the --prefix-paths flag. On one project, it would just redirect everything back to the index. On another project the page never loaded and the console spit out a 'TypeError: t is undefined' with a stack trace that isn't very helpful because it is a production build. In both cases, if I removed the pathPrefix line from my gatsby-config.js, and then ran gatsby build and gatsby serve, then everything would work.

Steps to reproduce
Define pathPrefix in a project's gatsby-config.js file, build, and serve (without using the --prefix-paths flag

Most helpful comment

@slightlyoffbeat This should be fixed in Gatsby v1.9.149.

All 9 comments

@slightlyoffbeat I ran into the same problem, reported here: https://github.com/gatsbyjs/gatsby/issues/2551

@m-allanson this looks like it could indeed be the problem — could you put together a PR fixing the check?

@KyleAMathews Yep, will do. There's another PR that I want to get to first, I'm aiming to have time for both next week.

Hey, I also just noticed the same problem with the gatsby-advanced-starter. Is there a PR for this now?

I've not looked at this yet. If anyone else wants to jump in, please do.

@slightlyoffbeat This should be fixed in Gatsby v1.9.149.

@m-allanson awesome! I'll give it a try.

i have same problems. i use --prefix-paths and i defined pathPrefix.
my gatsby version is "gatsby": "^1.9.153",
but i have this issue!

Hey @milad1367 can you open a new issue for this?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

3CordGuy picture 3CordGuy  Â·  3Comments

ghost picture ghost  Â·  3Comments

ferMartz picture ferMartz  Â·  3Comments

hobochild picture hobochild  Â·  3Comments

Oppenheimer1 picture Oppenheimer1  Â·  3Comments