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

class:list works as expected in development, but not in production build #7712

Closed
1 task
denniskasper opened this issue Jul 18, 2023 · 4 comments
Closed
1 task

Comments

@denniskasper
Copy link

What version of astro are you using?

2.8.4

Are you using an SSR adapter? If so, which one?

none

What package manager are you using?

npm

What operating system are you using?

linux

What browser are you using?

chrome

Describe the Bug

when running the app in development

npm run dev

the two navigation links get highlighted as expected, current route is marked with a red box.

however, when the app gets build and run in production

npm run build
npm run preview

the links are not properly highlighted.

What's the expected result?

expect same behaviour in dev and prod.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-jeaxqj?file=package.json

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Jul 18, 2023
@lilnasy
Copy link
Contributor

lilnasy commented Jul 18, 2023

Thanks for the reproduction, it was super helpful!

I don't believe this is necessarily an issue of astro's dev-build disparity.

You would run into in dev as well if you visit /about/, instead of /about. The code in ClassList.astro does not account for the trailing slash that the static build uses when rendering your pages.

We could default to removing the trailing slash during production builds, but a page similar to yours might still see "disparities" when visiting without the slash in dev mode.

@lilnasy lilnasy added the needs response Issue needs response from OP label Jul 18, 2023
@lilnasy
Copy link
Contributor

lilnasy commented Jul 18, 2023

And you can always set build.format to "file" to omit the trailing slash for your project.

https://docs.astro.build/en/reference/configuration-reference/#buildformat

@lilnasy
Copy link
Contributor

lilnasy commented Jul 19, 2023

After looking around more, I see the root cause (unexpected trailing slash) is being tracked in another issue: #5630. It will be considered for the next major version, 3.0.

I think we can close this issue as a duplicate. If you think this should not be the case, feel free to reopen.

@lilnasy lilnasy closed this as not planned Won't fix, can't repro, duplicate, stale Jul 19, 2023
@lilnasy lilnasy removed needs response Issue needs response from OP needs triage Issue needs to be triaged labels Jul 19, 2023
@denniskasper
Copy link
Author

hi @lilnasy,

thank you very much, that solves my problem.

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

No branches or pull requests

2 participants