How to reference CSS from libraries installed via npm?
So for example say I installed something:
npm install --save something
and it downloads into
and it has a folder in there perhaps called
styles and in that folder you have
something.css. How would I include that css file in my html document (if my html document was along-side the
I mean I could do this in my html head:
<link rel="stylesheet" href="./node_modules/something/styles/something.css" type="text/css" media="screen" />
But it feels wrong to go dig in your
node_modules directory for stuff. Especially if the html document perhaps needs to get minified and then thrown into some
./dist/ directory. Because then the path to
something.css is off..
Isn't there a way to simply just go:
<link rel="stylesheet" href="something.css" type="text/css" media="screen" />
in your html document - regardless of where it's sitting in your project structure - and it'll just know where to go find that css file?
There is a package for this called
In webpack you can require css like
require('bootstrap.css'), this is why installing css via npm quite useful
if you don't have it, you can create a npm script task that would require (with fs.readFile) all the css files from the node_modules, compile them into single file (which is what