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

Build fails with custom theme and no css #209

Closed
domnantas opened this issue Jan 21, 2021 · 2 comments · Fixed by #239
Closed

Build fails with custom theme and no css #209

domnantas opened this issue Jan 21, 2021 · 2 comments · Fixed by #239
Labels
bug Something isn't working

Comments

@domnantas
Copy link
Contributor

domnantas commented Jan 21, 2021

Describe the bug
I started building a custom theme and haven't imported any css to index.js yet. Running vitepress build throws an error:

$ vitepress build
vitepress v0.11.4
vite v2.0.0-beta.35
✓ building client + server bundles...
✖ rendering pages...
build error:
 TypeError: Cannot read property 'fileName' of undefined
    at Object.renderPage (/Users/fistmenaruto/Projects/domnantas.lt/node_modules/vitepress/dist/node/build/render.js:53:61)
    at async Object.build (/Users/fistmenaruto/Projects/domnantas.lt/node_modules/vitepress/dist/node/build/build.js:29:17)
error Command failed with exit code 1.

render.js:53 is trying to get cssChunk.fileName:

<link rel="stylesheet" href="${siteData.base}${cssChunk.fileName}">

but it is undefined since there are not css chunks.

The same happens if you try to import an empty .css file to index.js.

vitepress dev does not throw the error.

To Reproduce
Steps to reproduce the behavior:

Reproduction repo: https://github.com/domnantas/domnantas.lt/tree/no-css-chunks

Expected behavior
Build should not fail when building without css

System Info

  • vitepress version: v0.11.4
  • vite version: v2.0.0-beta.35
  • Node version: v15.5.1
  • OS version: MacOS 11.0.1

Additional context

`
...
${cssChunk ? `<link rel="stylesheet" href="${siteData.base}${cssChunk.fileName}">` : ""}
...
`

would fix this, but maybe there are better ways

@domnantas domnantas added the bug: pending triage Maybe a bug, waiting for confirmation label Jan 21, 2021
@kiaking kiaking added bug Something isn't working and removed bug: pending triage Maybe a bug, waiting for confirmation labels Feb 10, 2021
@kiaking
Copy link
Member

kiaking commented Feb 10, 2021

Good catch! Thanks for the report. I think your fix is reasonable. If there're no css files, we should just stop requiring it. Would you like to make a PR? 👀

@domnantas
Copy link
Contributor Author

Sure, I can do that

domnantas pushed a commit to domnantas/vitepress that referenced this issue Feb 11, 2021
kiaking added a commit that referenced this issue Apr 8, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants