question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

preact build ignores CSS files

See original GitHub issue

Do you want to request a feature or report a bug? Bug

What is the current behaviour? When importing a CSS file, preact build ignores it while preact watch puts it in the build.

If the current behaviour is a bug, please provide the steps to reproduce. Import a CSS file without specifying imports.

import "@material/radio/dist/mdc.radio.css";

And run build. The CSS file will not be in the build folder and the page will miss this styles.

What is the expected behaviour? Preact bundles the styles in the CSS file, without changing the class names.

If this is a feature request, what is motivation or use case for changing the behaviour?

Please mention other relevant information.

Please paste the results of preact info here. Unknown argument: info

Version is 2.2.1

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
ForsakenHarmonycommented, Mar 28, 2020

The issue might happen if you include the css files in src/components or src/routes, because files imported from there get treated as css modules

2reactions
bojan88commented, Dec 27, 2019

@DerDrodt sorry, my bad. I didn’t quite understand the problem.

I have 2 possible workarounds for you:

  1. I think CSS files included in src/index.js don’t have hashed class names. So moving your import "@material/radio/dist/mdc.radio.css"; to src/index.js might solve your issue.
  2. Install SASS and include your file like this from another .scss file:
:global {
  @import "@material/radio/dist/mdc.radio.css";
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Importing CSS as React/Preact components with webpack ...
I'm building an app that is supposed to be embedded on 3rd party websites and for such kind of applications the build size...
Read more >
How can I set a CSS name not to be a hash in a Webpack ...
1: At the app level, you can add the following configuration to your Webpack to disable CSS modules. · 2: At the file...
Read more >
Advanced Features: Next.js Compiler
The Next.js Compiler, written in Rust using SWC, allows Next.js to transform and minify your JavaScript code for production. This replaces Babel for...
Read more >
Common Error Details - Snowpack
The fix for .css files is similar to JS. Prefix a ./ to the import path like so: - @import ...
Read more >
ESM>CDN
Create modern(es2015+) web apps easily with NPM packages in browser/deno. ... This only works when the NPM package imports CSS files in JS...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found