Skip to content

Convert css into different formats (cssToJson, camelizedJson etc)

License

Notifications You must be signed in to change notification settings

DavideDaniel/convert-css

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

convert-css

Parse and convert css. The focus is on JSON as it's needed for other services, and other easier conversions like modules in js for css-in-js.

Install

$ npm install convert-css --save

Usage

const fs = require('fs');
const { cssToCamelizedJson } = require('convert-css');

const handleErr = (err) => {
  if(err) {
    console.error(err);
  }
};

fs.readFile('./my.css', 'utf-8', (err, data) => {
  handleErr(err);

  const cssText = data.toString();
  const cssInJs = 'module.exports = ' + JSON.stringify(
    cssToCamelizedJson(data), null, 2
  );

  fs.writeFile('./myCss.js', Buffer.from(cssInJs), (error) => {
    handleErr(error)
    console.log('done!')
  });
});

About

Convert css into different formats (cssToJson, camelizedJson etc)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published