Socket
Book a DemoInstallSign in
Socket

css-to-js-nodejs

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css-to-js-nodejs

CSS in JS for NodeJS API's

latest
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

CSS-in-JS-NodeJS

Installation

npm install --save css-in-js-nodejs

Example

Given an example css file (test.css)

.main-wrapper {
    flex-direction: row;
    display: flex;
    flex: 1;
  }
  #content {
    flex: 1;
  }
  ul {
    padding: 20px 0;
    flex: 1;
  }
  li {
    font-family:'Lato';
    color: whitesmoke;
    line-height: 44px;
  }

  @media screen and (max-width: 992px) {
    body {
      background-color: blue;
    }
  }

html {
    font-family: Gill Sans Extrabold, sans-serif;
    mask-image: url("masks.svg#mask1");
}

test.js

import fs from 'fs';
import cssToJS from 'css-to-js-nodejs';

const input = fs.readFileSync('./test.css', 'utf8');

const output = main(input);
console.log(output)
/*

{
  '.main-wrapper': { flexDirection: 'row', display: 'flex', flex: '1' },
  '#content': { flex: '1' },
  ul: { padding: '20px 0', flex: '1' },
  li: { fontFamily: "'Lato'", color: 'whitesmoke', lineHeight: '44px' },
  'screen and (max-width: 992px)': { body: { backgroundColor: 'blue' } },
  html: {
    fontFamily: 'Gill Sans Extrabold, sans-serif',
    maskImage: 'url("masks.svg#mask1")'
  }
}

*/

Need help or want to donate to help me make Open Source projects?

  • Send me a message on Twitter!
  • Donate

Keywords

css

FAQs

Package last updated on 13 May 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts