For instance, let's say I installed a package:
npm install --save package
and it gets saved in
./node_modules/package/
Inside that folder, there might be a directory named styles
and within that directory, you could find style.css
. How can I link this css file in my html document (assuming my html file is next to the node-modules
folder)?
I know I could include it in the head of my html like this:
<link rel="stylesheet" href="./node_modules/package/styles/style.css" type="text/css" media="screen" />
However, it doesn't feel right to go searching in your node_modules
folder for resources, especially if the html document needs to be minified and moved to a different ./dist/
directory. This would mess up the path to
style.css</code.</p>
<p>Is there a way to just do this instead:</p>
<pre><code><link rel="stylesheet" href="style.css" type="text/css" media="screen" />
in your html document - without worrying about its location in the project structure - and have it automatically locate the css file?