1. vueify-insert-css
insert a string of css into the <head>
vueify-insert-css
Package: vueify-insert-css
Created by: substack
Last modified: Tue, 28 Jun 2022 20:54:55 GMT
Version: 1.0.0
License: MIT
Downloads: 7,647
Repository: https://github.com/substack/insert-css

Install

npm install vueify-insert-css
yarn add vueify-insert-css

insert-css

insert a string of css into the <head>

browser support

example

suppose we've got some css:

 body {
    background-color: purple;
    color: yellow;
}

and we want to bundle that css into a js file so that we can write an entirely
self-contained module:

 var fs = require('fs');
var insertCss = require('insert-css');
var css = fs.readFileSync(__dirname + '/style.css');
insertCss(css);
document.body.appendChild(document.createTextNode('HELLO CRUEL WORLD'));

optionally prepend the css to the head with the prepend option:

 insertCss(css, { prepend: true });

compile with browserify using
brfs to inline the fs.readFile()
call:

$ browserify -t brfs insert.js > bundle.js

Now plop that bundle.js into a script tag and you'll have a self-contained js
blob with inline css!

 <html>
  <head></head>
  <body>
    <script src="bundle.js"></script>
  </body>
</html>

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin