What does this loader do?
There is a simple explanation missing what this loader is for and what it does. Just two sentences would be awesome! Thx.
@MiMaMuh The first two code blocks in the README are commented with a description of what the code does:
require("style!raw!./file.css");
// add rules in file.css to document
In this case, the contents of ./file.css will be added to the document.
Still have no idea about what this loader is about ? How does it work ? Where does it load css rules etc. It would be great to hear a clear explanation.
It loads all the rules from your css files inside the <head> tag with the proper <style> tag
What they mean is that it "inlines" the styles like <style> all my styles embedded here </style> - so they are not external but in the <head> of the document. It does have an option to load external styles by adding style/url to the loader
From readme:
require("style/url!file!./file.css"); // => add a
<link rel="stylesheet">to file.css to document
@luisrudge @MiMaMuh If you don’t understand how style-loader works or where it loads styles, you should probably read more about webpack before tackling specific loaders.
Have you got webpack running in your project already? If not, please do that before asking how a loader works. Once you wrap your head around the basics of webpack, style-loader (and every other loader) will make sense.
If you’re unsure where to begin, there are dozens (probably hundreds by now) of boilerplate projects that you can get running quite easily. I recommend very minimal boilerplate projects (webpack config + a few files).
webpack-howto by Pete Hunt is a good place to start: https://github.com/petehunt/webpack-howto
thanks @meyer .
Dupe of #70. Note that we're working on adding better description in readme's for loaders soon.