Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

babel-plugin-transform-inline-localize-css-import

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-transform-inline-localize-css-import

**Inline and localize `import theme from './Component.css'` to {classNames, code}.

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

babel-plugin-transform-inline-localize-css-import-import

Version Build Status License Downloads

Inline and localize import theme from './Component.css' to {classNames, code}.

This is similar to css modules localize as it will allow you to localize class names and animations.

Combining with substack/insert-css provides a simple solution component based website or libraries styling.

Quickstart

npm install babel-plugin-transform-inline-localize-css-import --save-dev

.babelrc

{
  "plugins": [
    ["babel-plugin-transform-inline-localize-css-import", {
      "localFormat": "$cssFilename__$token"
    }]
  ]
}

Component.js

import theme from './Component.css';

Component.css

.item {
  color: blue;
}

.itemSelected {
  color: yellow;
  animation-name: hide;
}

@keyframes hide {0%{opacity:0}}
babel Component.js

# var theme = {
#   classNames: {
#     item: 'Component__item',
#     itemSelected: 'Component__itemSelected'
#   },
#   code: 'Component__item \n{  color: blue}\n\nComponent__itemSelected \n{  color: yellow;\nanimation-name: Component__hide }\n\n@keyframes Component__hide {0%{opacity: 0}}'
# }

Configuration

  • localFormat (string): How to localize tokens. Available variables:
    • $cssFilename: Filename, without extension, of the imported CSS file.
    • $jsFilename: Filename, without extension of the module JavaScript file.
    • $token: Current class name or animation-name to replace.

Test

Runs tests and lint.

npm test

Dev

Runs tests in watch mode.

npm run dev

Release

npm run release

Keywords

babel-plugin

FAQs

Package last updated on 03 Oct 2016

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