@vsr/css-to-js

Converts css code to JS code that can inject styles.

Usage no npm install needed!

<script type="module">
  import vsrCssToJs from 'https://cdn.skypack.dev/@vsr/css-to-js';
</script>

README

CSS to JS

This module converts CSS code to JS code, such that running the JS code in browser would apply the styles defined by the CSS code.

This is helpful when you can't or don't want to add or insert a style tag but would like to apply the styles.

Install

npm i @vsr/css-to-js

CLI

npx @vsr/css-to-js -i my-css-file.css -o css-embed.js

API

const fs = require('fs');
const { cssToJs } = require('@vsr/css-to-js');

const css = fs.readFileSync('./test/styles/pure-min.css').toString();
console.log(cssToJs(css));

TODO

  • develop api
  • write tests
  • develop script generator
  • develop cli interface