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

CSS import breaks webpack 5 compilation #4287

Closed
vincentferniotoclock opened this issue Sep 27, 2021 · 12 comments
Closed

CSS import breaks webpack 5 compilation #4287

vincentferniotoclock opened this issue Sep 27, 2021 · 12 comments

Comments

@vincentferniotoclock
Copy link

Bug Report

With Webpack 5 and css-loader 6, the CSS imports breaks the compilation.

Steps

Starts a new react app with webpack 5 and css-loader v6. Imports Semantic UI css in root component and it should stops working.

Expected Result

CSS should import correctly and app running as expected

Actual Result

An error occurs in

TypeError: Cannot read property 'get' of undefined
during rendering of asset asset/inline|data:application/x-font-ttf;charset=utf-8;;base64,AAEAAAAOAIAAAwBgT1Mv...

Version

2.0.4

Fix

The main reason for this is an extra ";" at line 19990 of semantic.css
If removed, everything goes fine.

@font-face {
  font-family: 'Step';
  src: url(data:application/x-font-ttf;charset=utf-8;;base64,AAEAAAAOAIAAAw... // this line
}
@welcome
Copy link

welcome bot commented Sep 27, 2021

👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you've completed all the fields in the issue template so we can best help.

We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

@dryerflyer
Copy link

@vincentferniotoclock I am experiencing this as well. Have you found a work-around without modifying semantic itself?

@layershifter
Copy link
Member

We have only React components in this repo so we can't handle CSS issues, it should be.

This should be reported into the upstream repo: https://github.com/Semantic-Org/Semantic-UI. The problem is that it's dead 🙄 Reasonable solution is to switch to https://github.com/fomantic/Fomantic-UI.

@fholzer
Copy link

fholzer commented Jan 1, 2022

Maybe it makes sense to mention that support for React is still missing in Formatic-UI, so it's not a drop-in replacement for semantic-ui-react. Just for semantic-ui-css, by using fomantic-ui-css, though I ran into the same issue doing that. I found that instead of installing semantic-ui-css, adding css as link to my React app's public/index.html works fine. E.g.:

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.css" />

@jojiseb
Copy link

jojiseb commented Jan 10, 2022

@fholzer I also ran into the same issue while using semantic-ui-css and adding the css as link to my React app solved the issue.

@yedidyas
Copy link

@fholzer The only solution that worked for me, thanks

@layershifter
Copy link
Member

This issue is extremely annoying, to workaround it I created @semantic-ui-react/css-patch, works with semantic-ui-css & semantic-ui-less.

To use it:

  • Install it
    yarn add --dev @semantic-ui-react/css-patch
    # or
    npm install --dev @semantic-ui-react/css-patch
  • Add it as a postinstall script to your package.json
    {
     "scripts": {
       "postinstall": "semantic-ui-css-patch"
     }
    }

image

@cmcode-dev
Copy link
Contributor

cmcode-dev commented Jan 19, 2022

@layershifter Thank you for creating this fix. It worked perfectly and solved this issue for my Electron React Boilerplate project as well - sharing the steps I ran, which were basically what you recommended:

  1. npm install --dev @semantic-ui-react/css-patch
  2. Add semantic-ui-css-patch && .... to the scripts section in package.json, like pictured:
    image
  3. Run npm install again (so that it runs the patch)
  4. npm start and your app works!

mvidalgarcia added a commit to mvidalgarcia/reana-ui that referenced this issue Jan 25, 2022
- upgrade semantic-ui deps to latest
- install `@semantic-ui-react/css-patch` to fix `semantic-ui-css` issue (Semantic-Org/Semantic-UI-React#4287 (comment))

closes reanahub#204
mvidalgarcia added a commit to mvidalgarcia/reana-ui that referenced this issue Jan 26, 2022
- upgrade semantic-ui deps to latest
- install `@semantic-ui-react/css-patch` to fix `semantic-ui-css` issue (Semantic-Org/Semantic-UI-React#4287 (comment))

closes reanahub#204
ntarocco added a commit to NRodriguezcuellar/react-searchkit that referenced this issue Jan 31, 2022
* upgrades React-SemanticUI
* fixes code style
* adds semantic-ui-css-patch to fix Semantic-Org/Semantic-UI-React#4287
* fixes prettier warnings
ntarocco added a commit to NRodriguezcuellar/react-searchkit that referenced this issue Jan 31, 2022
* upgrades React-SemanticUI
* fixes code style
* adds semantic-ui-css-patch to fix Semantic-Org/Semantic-UI-React#4287
* fixes prettier warnings
ntarocco added a commit to inveniosoftware/react-searchkit that referenced this issue Jan 31, 2022
* upgrades React-SemanticUI
* fixes code style
* adds semantic-ui-css-patch to fix Semantic-Org/Semantic-UI-React#4287
* fixes prettier warnings
rieckpil added a commit to rieckpil/testing-spring-boot-applications-masterclass that referenced this issue Feb 5, 2022
@bubbaspaarx
Copy link

I am still receiving an error. I believe it's related to the 'step.overrides' file. The URL appears to be the same as the original semantic.css + step.css files. The double semi-colon appears still

@layershifter
Copy link
Member

I am still receiving an error. I believe it's related to the 'step.overrides' file. The URL appears to be the same as the original semantic.css + step.css files. The double semi-colon appears still

This patch tool (#4287 (comment)) covers changes in step.overrides in semantic-ui-less and CSS files in semantic-ui-css:
https://github.com/layershifter/semantic-ui-tools/blob/60b209943abde43ee207a4b8acdbe050e8f2f219/packages/css-patch/src/index.js#L19-L26

@bubbaspaarx please provide a repository with a repro case that I clone and check.

@bubbaspaarx
Copy link

Apologies. I realised my mistake. The patch works perfectly. One of our devs had created themes and imported the entire semantic package to the code base. Apologies.

@mpaccione
Copy link

I encourage anyone who has information about the engineer that introduced the double comma bug in semantic ui react to let me know their details. I will promptly hit them with a truck. That is all, thank you.

StevenMassaro added a commit to StevenMassaro/music-client that referenced this issue Jun 29, 2022
StevenMassaro added a commit to StevenMassaro/music-client that referenced this issue Jun 29, 2022
…nd/music (#20)

* Bump react-scripts in /music-client-ui/src/frontend/music

Bumps [react-scripts](https://github.com/facebook/create-react-app/tree/HEAD/packages/react-scripts) from 3.4.4 to 5.0.1.
- [Release notes](https://github.com/facebook/create-react-app/releases)
- [Changelog](https://github.com/facebook/create-react-app/blob/main/CHANGELOG-3.x.md)
- [Commits](https://github.com/facebook/create-react-app/commits/react-scripts@5.0.1/packages/react-scripts)

---
updated-dependencies:
- dependency-name: react-scripts
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* bump version of node

* resolve compilation error with useContextMenu

* resolve semantic-ui-css import on webpack 5

see Semantic-Org/Semantic-UI-React#4287 for more information

* remove unused type variable

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Steven Massaro <steven.massaro.web@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants