jpedroschmitz / gatsby-starter-ts

TypeScript starter for Gatsby. No plugins and styling. Exactly the necessary to start. Ready for Gatsby 5 🔥
https://typescript.gatsbyjs.io
MIT License
305 stars 27 forks source link

Building with --path-prefix flag seems to error out #726

Closed vim-usds closed 1 year ago

vim-usds commented 1 year ago

@jpedroschmitz

Gratitude

First of all thank you for the awesome repo! I'm hoping it can be used for upcoming projects at USDS.

Motivation

During the CI/CD pipeline, we needed to change the pathPrefix. Gatsby talks about a way to do that here.

How to reproduce

I cloned this repo and made the following changes:

In gatsby-config.ts:

const config: GatsbyConfig = {
  :
  :
  jsxRuntime: `automatic`,
  siteMetadata: {
    pathPrefix: `/blog`, //added this
  }
};

✅ ran gatsby build --prefix-paths with no errors:

I would have expected the pages to have updated with the prefix here ❓

Pages

┌ src/pages/404.tsx
│ ├   /404/
│ └   /404.html
└ src/pages/index.tsx
  └   /

✅ ran gatsby serve --prefix-paths with no errors:

⠀
You can now view gatsby-starter-ts in the browser.
⠀
  http://localhost:9000/

When I attempt to navigate to the localhost at port 9000, the app loads, however, when attempting to go to /blog the page is not found.

gatsby start, gatsby build both work great without the --prefix-paths flag.

What I tried

  1. I tried adding another page ❌
  2. I tried using npm and not pnpm ❌

What I plan to try next

Any ideas would be awesome! Thank you!

vim-usds commented 1 year ago

My config file was wrong, using this config file works better:

const config: GatsbyConfig = {
  :
  :
  jsxRuntime: `automatic`,
  pathPrefix: `/blog`, //added this
};

Followed by gatsby build --prefix-paths

jpedroschmitz commented 1 year ago

That's awesome, Vim! Glad that you like the project and plan to use it at USDS!