New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-css-modules

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-css-modules

A lean, framework agnostic (S)CSS (modules) in JS library.

  • 0.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

babel-plugin-css-modules

A lean, framework agnostic (S)CSS (modules) in JS library.

Why should you use babel-plugin-css-modules?

It's very lightweight -- nearly all work is done at compile time. The entire runtime shipped is only five lines of unminized JavaScript code.

(function() {
  var ss = document.createElement("style");
  ss.innerHTML = `${styles}`;
  document.head.appendChild(ss);
})();

That's 107 bytes minimized.

Why should you not use babel-plugin-css-modules?

If you ever plan to server-side render -- or if you want to export a standard .css file. Those two issues are not in scope of babel-plugin-css-modules as of now.

But what does it look like?

The minimal example is:

let classes = styles`
    body {
        margin: 0
    }

    .container {
        h1 {
            font-size: 50px;
        }
        :before {
            content: "1. ";
        }
    }
`;

document.body.innerHTML = `
    <div class="${classes.container}">
        <h1>This is a triumph.</h1>
    </div>
`;
Installing
npm i -D babel-plugin-css-modules
Now, how do I use it?

With Babel! You must have this placed in your .babelrc

{
  "plugins": ["css-modules"]
}

Keywords

FAQs

Package last updated on 20 Dec 2018

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc