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.

How do you include a CSS file from node_modules without it prefixing?

See original GitHub issue

When I do …

import 'react-select/dist/react-select.css';

Then the css is dumped to the page but with all of the extra stuff in the name, expecting that I’ll be using the withStyles method, but it’s not my component and doesn’t use that method. With how all of this is configured, how can I bypass the renames?

Would it be a good idea to modify this starter kit to have a css loader for anything in the node_modules directory where it doesn’t do all the class renaming since components asking you to include their css this way is common and the current set up breaks the css.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
janceChuncommented, Aug 24, 2016

it works for me to add
@import ‘~bootstrap/dist/css/bootstrap’; @import ‘~bootstrap/dist/css/bootstrap-theme’; in core.scss

4reactions
frenzzycommented, Sep 7, 2016

Replace postcss-import with postcss-partial-import and use like so:

/* YourStyles.css */
:global {
  @import 'react-select/dist/react-select.css';
  /* or @import '~/react-select/dist/react-select.css' */
  /* or @import '../../../node_modules/react-select/dist/react-select.css' */
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Import CSS from "node_modules" in Webpack - Stack Overflow
You can import files relative to your project's root (resolving node_modules/ from the root folder) by prefixing with a tilde ~ :
Read more >
How do I include node_modules css files? #1789 - GitHub
I'm having a hard time figuring this out. I have all these node_modules which include the css files I need but I can...
Read more >
CSS - Parcel
To use CSS modules, create a file with the .module.css extension, and import it from a JavaScript file with a namespace import. Then,...
Read more >
css-loader | webpack - JS.ORG
file.js import css from "file.css";. webpack.config.js ... assets from a node_modules path (include resolve.modules ) and for alias , prefix it with a...
Read more >
Working with CSS - Vue CLI
Note if you want to reference a file inside an npm dependency or via webpack alias, the path must be prefixed with ~...
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