Skip to content

fix(core): allow empty static directories#7285

Merged
Josh-Cena merged 3 commits intomainfrom
jc/fix-static-dirs
May 2, 2022
Merged

fix(core): allow empty static directories#7285
Josh-Cena merged 3 commits intomainfrom
jc/fix-static-dirs

Conversation

@Josh-Cena
Copy link
Collaborator

@Josh-Cena Josh-Cena commented May 2, 2022

Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
    • I really want to add tests but I don't know how to persist it, so see test plan below
  • If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

It turns out that simply ensureDir is not sufficient to make build succeed with an empty static folder. To reproduce, do mkdir website/_dogfooding/emptyStaticDir, and add _dogfooding/emptyStaticDir to the staticDirectories list, then run yarn build -l en. Server build errors with:

unable to locate '/.../docusaurus/website/_dogfooding/emptyStaticDir/**/*' glob

This seems to be a bad thing to happen for a glob pattern, but just in case, I've simply filtered out all non-existent directories instead of creating empty ones. This also means the user doesn't magically have a static folder created after every build.

Test Plan

Tested locally with the above reproduction. I don't really know how to add a dogfooding test—my suspicion is it's impossible to do it in a simple way, because empty dirs aren't checked in to git... I just added a directory that doesn't exist, which should do half the job.

Related issues/PRs

#6311

@Josh-Cena Josh-Cena added the pr: bug fix This PR fixes a bug in a past release. label May 2, 2022
@Josh-Cena Josh-Cena requested review from lex111 and slorber as code owners May 2, 2022 08:14
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label May 2, 2022
@netlify
Copy link

netlify bot commented May 2, 2022

[V2]

Name Link
🔨 Latest commit 2633355
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/626f92ecd63bb80007e2f430
😎 Deploy Preview https://deploy-preview-7285--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions
Copy link

github-actions bot commented May 2, 2022

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟠 Performance 65
🟢 Accessibility 100
🟢 Best practices 92
🟢 SEO 100
🟢 PWA 90

Lighthouse ran on https://deploy-preview-7285--docusaurus-2.netlify.app/

@netlify
Copy link

netlify bot commented May 2, 2022

[V2]

Name Link
🔨 Latest commit 6a73084
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/626f944e5ba07e0008e1bde1
😎 Deploy Preview https://deploy-preview-7285--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions
Copy link

github-actions bot commented May 2, 2022

Size Change: +75 B (0%)

Total Size: 805 kB

Filename Size Change
website/build/assets/js/main.********.js 609 kB +75 B (0%)
ℹ️ View Unchanged
Filename Size
website/.docusaurus/globalData.json 50.5 kB
website/build/assets/css/styles.********.css 107 kB
website/build/index.html 38.8 kB

compressed-size-action

@Josh-Cena Josh-Cena merged commit e1b7171 into main May 2, 2022
@Josh-Cena Josh-Cena deleted the jc/fix-static-dirs branch May 2, 2022 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA pr: bug fix This PR fixes a bug in a past release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants