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

Custom css not loaded the same way with yarn start and yarn build #4231

Closed
ArtFlag opened this issue Feb 17, 2021 · 8 comments · Fixed by #4240
Closed

Custom css not loaded the same way with yarn start and yarn build #4231

ArtFlag opened this issue Feb 17, 2021 · 8 comments · Fixed by #4240
Labels
bug An error in the Docusaurus core causing instability or issues with its execution

Comments

@ArtFlag
Copy link
Contributor

ArtFlag commented Feb 17, 2021

🐛 Bug Report

I have a simple setup using the classic theme in which I've modified the admonition styling.

In my case, I have only overridden the admonition class and admonition-tip|note|important classes. I didn't touch the alert class which is also used in the admonitions.

  • When I build my output with yarn start I get this, which I what I expect:

Screenshot 2021-02-17 at 08 30 08

Screenshot 2021-02-17 at 08 30 16

  • When I build my output with yarn build I get this, which is unexpected:

Screenshot 2021-02-17 at 08 30 23

Screenshot 2021-02-17 at 08 30 27

Somehow, the classes are not in the same order, which might be the reason (??).

Have you read the Contributing Guidelines on issues?

Yes

To Reproduce

  1. Add some admonition classes to custom.css
  2. Build with yarn start
  3. Build with yarn build
  4. Compare

Expected behavior

I should get the same visual output.

Actual Behavior

I do not get the same visual output.

Your Environment

  • Docusaurus version used:
 "dependencies": {
    "@docusaurus/core": "2.0.0-alpha.70",
    "@docusaurus/preset-classic": "2.0.0-alpha.70",
    "@docusaurus/theme-search-algolia": "^2.0.0-alpha.70",
    "@mdx-js/react": "^1.6.21",
    "antd": "^4.9.4",
    "clsx": "^1.1.1",
    "core-js": "^3.8.1",
    "docusaurus-plugin-sass": "^0.1.11",
    "mobx": "^6.0.4",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "redoc": "^2.0.0-rc.45",
    "redocusaurus": "^0.2.2",
    "styled-components": "^5.2.1"
  },
  • Environment name and version: Node v15.3.0. FF 85.0.2. Chrome 88.0.4324.150
  • Operating system and version:MacOs 10.15.7

Reproducible Demo

See codesandbox but obviously that's not going to help build the packaged app.

@ArtFlag ArtFlag added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Feb 17, 2021
@slorber
Copy link
Collaborator

slorber commented Feb 17, 2021

I suspect this is related to #3678

We should find a way to ensure that the custom CSS provided by the user is always at the end of the stylesheet and allows to override properly the theme CSS modules + infima

@slorber
Copy link
Collaborator

slorber commented Feb 18, 2021

@ArtFlag can you try the @canary npm dist tag and see if your issue is fixed by #4240 ?

Otherwise we'll re-open

@ArtFlag
Copy link
Contributor Author

ArtFlag commented Feb 18, 2021

Hi Sébastien,

Thanks for the quick action and follow-up 👍

If using the canary dist is just about yarn remove docusaurus && yarn install docusaurus@canary, then I experience the same problem 😢

If not, then how should I use the canary dist?

@lex111
Copy link
Contributor

lex111 commented Feb 18, 2021

Apparently the canary release for fix to this issue was not created https://github.com/facebook/docusaurus/runs/1927814807

@slorber
Copy link
Collaborator

slorber commented Feb 19, 2021

@ArtFlag you can use canary versions found in https://www.npmjs.com/package/@docusaurus/core

    "@docusaurus/core": "2.0.0-alpha.a58baacdc",
    "@docusaurus/preset-classic": "2.0.0-alpha.a58baacdc",

image

@ArtFlag
Copy link
Contributor Author

ArtFlag commented Feb 20, 2021

Using these versions, I get scss modules errors in 2 of my components that I didn't have with the latest non-canary versions:

ValidationError: Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema.
 - options has an unknown property 'onlyLocals'. These properties are valid:
   object { url?, import?, modules?, sourceMap?, importLoaders?, esModule? }

 @ ./docs/dev/entities.mdx
 @ ./.docusaurus/registry.js
 @ ./node_modules/@docusaurus/core/lib/client/exports/ComponentCreator.js
 @ ./.docusaurus/routes.js
 @ ./node_modules/@docusaurus/core/lib/client/clientEntry.js
 @ multi ./node_modules/react-dev-utils/webpackHotDevClient.js ./node_modules/@docusaurus/core/lib/client/clientEntry.js

I'm still using "docusaurus-plugin-sass": "^0.1.11". Is it expected or am I doing something wrong?

@slorber
Copy link
Collaborator

slorber commented Feb 20, 2021 via email

@ArtFlag
Copy link
Contributor Author

ArtFlag commented Feb 22, 2021

Your fix works 🥳 !

Thanks 👍

@Josh-Cena Josh-Cena removed the status: needs triage This issue has not been triaged by maintainers label Mar 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants