Search code examples
javascripthtmlcssbrowserify

Require stylesheets and inject them to html as link tag with browserify


I wanna try using browserify for building my projects. It looks pretty cool that I can require js files using relative paths, then bundle and minify that files alltogether. But it remains unclear to me yet, if I can automatically add that bundle to html as

<script src=".../.../bundle.min.js"></script>

And, if I can do a similar trick with css - somehow require css files, including vendor ones, bundle and minify that files and inject that bundled css to html head as <link> tag, not <style>.

Is that possible? If so how? Or, maybe such an idea itself is just a misunderstanding of how projects should be built? If so, where am I mistaking?


Solution

  • You should check browserify-css It allows the minification, inserting in another bundle css file.
    But the main function of browserify is to build the JavaScript files into a single main one, but not css processing. It just is not created for css.