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

css-customs-loader

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css-customs-loader

Exposes custom properties, custom media queries and custom selectors to JavaScript

  • 0.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

css-customs-loader

A webpack loader that exposes CSS customs to JavaScript.

Configuration

yarn add css-customs-loader postcss-loader postcss-preset-env

You need to add css-customs-loader before css-loader:

// webpack.config.js
module.exports = {
  // ...
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [
          'style-loader',
          {
            loader: 'css-customs-loader'
            // defaults
            options: {
              onlyLocals: false,
            },
          },
          'css-loader?importLoaders=1',
          'postcss-loader',
        ],
      },
    ],
  },
}

css-customs-loader detects any valid PostCSS configuration (including options passed to postcss-loader!), so let's create one. importFrom will point to a global.css file containing our customs and, for the sake of this example, we'll enable all features related to CSS customs:

// postcss.config.js
module.exports = {
  plugins: {
    'postcss-preset-env': {
      importFrom: 'src/global.css',
      features: {
        'custom-properties': true, // already enabled by default
        'custom-media-queries': true,
        'custom-selectors': true,
      },
    },
  },
}

Options

onlyLocals

This option should be enabled in situations like pre-rendering. You should combine it with onlyLocals option in css-loader v2 or css-loader/locals loader in css-loader v1. (Don't use style-loader when pre-rendering.)

Usage

See usage instructions in the main readme.

Keywords

FAQs

Package last updated on 29 Jan 2020

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