docusaurus: Enforcing dark mode not working in production
Have you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
Prerequisites
- I’m using the latest version of Docusaurus.
- I have tried the
npm run clearoryarn clearcommand. - I have tried
rm -rf node_modules yarn.lock package-lock.jsonand re-installing packages. - I have tried creating a repro with https://new.docusaurus.io.
- I have read the console error message carefully (if applicable).
Description
Hello everyone,
I hope someone can point me to a solution. Searching already for hours.
I try to load my website only in dark mode and use for that the settings:
colorMode: {
defaultMode: 'dark',
disableSwitch: false,
respectPrefersColorScheme: false,
},
It is working fine locally (using Webstorm) with docusaurus start and docusaurus build & docusaurus serve. But if I deploy the website to my NGINX server, the light mode is loading. If I enable the switch and activate the dark mode, everything works as expected. I can not find a solution to enforce the dark mode in production.
Any help is more then welcome.
Best Martin
Reproducible demo
No response
Steps to reproduce
- Create new project with ‘npx create-docusaurus@latest my-website classic --typescript’
- Build the project
- Deploy on NGINX
Expected behavior
Dark mode is always enabled
Actual behavior
Website loads with light mode.
Your environment
- Docusaurus version used: 3.4.0
- Environment name and version (e.g. Chrome 89, Node.js 16.4): Node.js 20.11.1
- Operating system and version (e.g. Ubuntu 20.04.2 LTS): (Live Deployment) Debian 12
- NGINX version: 1.22.1
Self-service
- I’d be willing to fix this bug myself.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 16 (3 by maintainers)
Thanks for the reply @slorber . I saw something else on my browsers (2 different devices), but it seems that an extension is interfering with it. When I tried in safe mode with no extensions enabled, I got
darkas the default too… Sorry that I didn’t check that deep myself. Thethemekey was not set in the storage of Firefox, both on working and non-working browsers. I’ll configure the experimental storage and you can consider this as resolved - I don’t think this is a Docusaurus issue.