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.

Brunch throws on CSS imports w/o css-modules

See original GitHub issue

Description

Brunch doesn’t require CSS. In projects like Spectacle there are requires like these:

  if (useDarkTheme) {
    require("../themes/default/dark.codemirror.css");
  } else {
    require("../themes/default/light.codemirror.css");
  }

Brunch can’t handle such requires, so it fails:

image

Quite confusing, because it’s problem with vendor not with my code itself.

Expected behavior

When Brunch meet styles require, then require should return a string with styles (?) or css-modules object (if they are enabled) and empty object (if they are disabled). I think it have to be discussed.

Actual behavior

Style modules isn’t defined and JS errors occurs.

Other useful files, when present (log, bower.json etc.)

  • Also mentioned in brunch/brunch#1473
  • Related issue in FormidableLabs/spectacle#291

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kockokcommented, May 4, 2017

I cannot require css even though postcss-brunch is installed. Or brunch will NEVER be able to require css?

0reactions
kockokcommented, May 4, 2017

@shvaikalesh

exports.plugins = {
  babel: {presets: ['latest', 'react']},
  postcss: {
    modules: true,
    processors: [
      require('autoprefixer')(['last 8 versions']),
      require('csswring')()
    ]
  }
};

Is this the way to enable it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Does brunch support npm packages with css modules? #1473
I'm trying to use an npm module that imports its own bundled css modules. e.g. ... Brunch throws on CSS imports w/o css-modules...
Read more >
CSS Modules Import is not applying css to html for "react-scripts"
Look at your import, there is a typo in the filename. Try changing it to. import styles from './App.Module.css';. If that doesn't work, ......
Read more >
Using CSS Module Scripts to import stylesheets - web.dev
Learn how to use CSS module scripts to import CSS stylesheets using the same syntax as JavaScript modules.
Read more >
CSS Modules-in-CSS Module Scripts - daverupert.com
Given this import statement: import sheet from './styles.css' assert {type: 'css'}; I don't see common ground between frameworks: – Web ...
Read more >
CSS Modules with React: The Complete Guide | by Suraj KC
CSS module makes CSS classes local for every component declared within by adding hashes in class names which are unique to each component,...
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