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.

Importing classnames installed via NPM while using Webpack

See original GitHub issue

Hi, firstly i’d like to thank you and the comunity for this amazing module, it certainly makes the life of anyone coding in React easier.

It seems i’m doing something wrong, yet i cant find what it is. You see, i’m coding in React with Typescript, therefore, i use import * as ClassNames from "classnames" to import your module into my code, but webpack seems unable to include it in the output bundle, forcing me to include it as a separate asset in my html. While this isn’t terribly annoying, it would be wonderfull if classnames could be bunbled with the rest of my code.

I hope you can help me, either by telling what i’m doing wrong or by showing me how to hack around this. Thanks in advanced!!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:15

github_iconTop GitHub Comments

18reactions
zpostencommented, Mar 10, 2018

Because there’s not really an “answer” on this thread, I wanted to supply the one that worked for me:

import * as classnames from 'classnames'
15reactions
AndyOGocommented, Jan 30, 2017

@ramarivera

I’m just curious, may I ask you to try this:

import classNames from 'classNames';

If that works, it is related to another bug I issued months ago: https://github.com/JedWatson/classnames/issues/82#issuecomment-218676799

Read more comments on GitHub >

github_iconTop Results From Across the Web

classnames - npm
A simple JavaScript utility for conditionally joining classNames together. Install with npm, Bower, or Yarn: # via npm npm install ...
Read more >
How to configure CSS Modules for webpack - LogRocket Blog
In this article, we will practice using CSS Modules with a webpack demo project in order to learn how to configure an app...
Read more >
style-loader - webpack
It's recommended to combine style-loader with the css-loader ... component-with-css-modules.js ... All locals (class names) stored in imported object.
Read more >
Installing an npm package and using it in TSX files
The error is saying that you're missing the classnames npm modue. react-super-select has it, along with lodash, in its peerDepedencies so ...
Read more >
Using CSS in React and TypeScript with Webpack 5
css-loader reads the referenced CSS file in the import statement ( app.css in our example). style-loader then put this CSS content into a...
Read more >

github_iconTop Related Medium Post

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