docusaurus: Css is not loading properly in build

🐛 Bug Report

I want to deploy the build folder, but the build folder css is all messed up. The pages has no styling. When I’m running in development mode the pages are loading fine, but in build mode, pages are not loading properly. Please see attached photos

Have you read the Contributing Guidelines on issues?

Yes

To Reproduce

  1. Clone the repo git clone https://github.com/react-native-bootstrap/react-native-bootstrap
  2. cd into website folder cd website
  3. Start development server and see website is working fine yarn start
  4. Not build the static website & open index.html in build folder yarn build

Expected behavior

The website should have looked like this

Screenshot_2020-05-31 React Native Bootstrap React Native Bootstrap(1)

Running index.html file from build folder should have worked fine, so that I can deploy it on github pages

Actual Behavior

Website looks like this after deploying build folder in gh-pages

Screenshot_2020-05-31 React Native Bootstrap React Native Bootstrap

Your Environment

  • Docusaurus version used: 2.0.0-alpha.56
  • Firefox 76.0.1 (64-bit)
  • Node.js v10.15.3
  • Operating system and version (desktop or mobile): Ubuntu 18.04

Reproducible Demo

The entire code is present here https://github.com/react-native-bootstrap/react-native-bootstrap/tree/master/website

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 2
  • Comments: 34 (4 by maintainers)

Most upvoted comments

You need a CNAME file as well in static with the contents react-native-boostrap.io.

This is not a Docusaurus problem, so I’m closing this.

Fixed it by setting this in the config:

  future: {
    v4: true,
    experimental_faster: true, <-- ADDED THIS
  },

Added some details regarding CSS not loading on Docosaurus 3.8 here.

Hi @sanjeevyadavIT ,

I have the same issue as you, Have you got any solution to it?

Also Just want to know, After running yarn build can we run a static website through a browser without running any server?

@AymaneHrouchможете ли вы создать репродукцию? Если у вас есть my-website/postcss.config.js, мне довольно сложно устранять неполадки, не видя всей настройки. Ваша репродукция Docusaurs здесь не содержит этого файла и не содержит никаких ссылок на «частное медицинское страхование», поэтому я полагаю, что это не репродукция выдала это сообщение об ошибке. Вероятно, это другая проблема. Можете ли вы создать новую специализированную проблему, чтобы мы могли исследовать эту проблему отдельно?

Спасибо@MohammadArk96. Можно ли просто отключить каскадные слои CSS и оставить прежнюю версию Node.js?

Например, используйте узел 22/24 с:

future: {
  v4: {
    useCssCascadeLayers: false,
    removeLegacyPostBuildHeadAttribute: true,
  },

} Эта проблема, похоже, связана с использованием каскадных слоев CSS для пользователей Windows. Это не совсем та же проблема, что и исходная (CSS не загружается), а скорее новая проблема (CSS загружается, но не содержит ожидаемых правил CSS). Вероятно, это связано с путями posix и путями Windows, я разберусь с этим как можно скорее.

Today, I installed version 3.8.0 for the first time and encountered missing styles in Docusaurus on Windows 11. I needed to deploy this application on Windows Server 2019 IIS, where this issue persisted. Your solution restored the styles to working condition.

@AymaneHrouch can you please create a repro? If you have a my-website/postcss.config.js, it’s quite hard for me to troubleshoot anything without seeing the whole setup. Your Docusaurs repro here doesn’t contain this file and doesn’t contain any reference to “private medical insurance” so I guess it’s not the repro that produced that error message. That’s probably a different issue. Can you create a new issue dedicated issue so that we can investigate that problem separately?


Thanks @MohammadArk96. Can you just turn off CSS Cascade Layers and keep the former Node.js version?

For example use Node 22/24 with:

    future: {
      v4: {
        useCssCascadeLayers: false,
        removeLegacyPostBuildHeadAttribute: true,
      },
   }

This problem looks related to using CSS Cascade Layers for Windows users. It’s not really the same issue as the original one (CSS is not loading), but rather a new issue (CSS is loading, but it doesn’t contain the expected CSS rules). This is probably related to posix paths vs Windows paths, I’ll look into it asap.

I had this issue fixed by setting v4 to false v4: false, // Improve compatibility with the upcoming Docusaurus v4

and downgrading nodejs to v20.14.0

i am facing this issue too with windows 11, can you tell me which css file is the problem? and where to find the correct one ?

@Cristy94 Thank you so much for sharing!!

I have the same problem, npm start shows correct css, on build it looks like this. There are no JS or network errors live.

Local:

Image

Live:

Image