Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

css-selector-loader

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css-selector-loader

css selector loader module for webpack, load css selectors and their style into js

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

npm node

CSS Selector Loader

Load CSS selectors and their styles into JS

Install

npm install css-selector-loader --save-dev

Usage

It's recommended to combine css-selector-loader with the postcss-loader

file.css

.foo {
    width: 100px;
    height: 100px;
}

.bar {
    width: var(--w)px;
    height: var(--h)px;
}

component.js

import {
    getFoo as getFooStyle
    getBar as getBarStyle
} from './file.css'

fooElement.style.cssText = getFooStyle();
barElement.style.cssText = getBarStyle({
    w: 50,
    h: 50
});

webpack.config.js

{
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [
          { loader: "css-selector-loader" },
          { loader: "postcss-loader" }
        ]
      }
    ]
  }
}

Options

NameTypeDefaultDescription
root{String}./helps inline local url(...)'s as data-uri's
camelCase{Boolean}trueEnable/disable transfering css selectors into camel-case
useVarTemplate{Boolean}trueEnable/disable use function arguments to replace with css variables

root

webpack.config.js

{
  loader: 'css-selector-loader',
  options: {
    root: path.resolve(__dirname, 'css')
  }
}

camelCase

webpack.config.js

{
  loader: 'css-selector-loader',
  options: {
    camelCase: false
  }
}

useVarTemplate

webpack.config.js

{
  loader: 'css-selector-loader',
  options: {
    useVarTemplate: false
  }
}

FAQs

Package last updated on 06 Jan 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