Socket
Socket
Sign inDemoInstall

css-modules-escaper

Package Overview
Dependencies
5
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    css-modules-escaper

postcss-plugin/webpack-loader for escape css-modules's compile


Version published
Maintainers
1
Install size
437 kB
Created

Changelog

Source

0.0.3

  • 【FIX】Handle all value of animation-name include 'none', 'initial', 'inherit', 'unset'

Readme

Source

why

The animation of inline style will not work when you use css-modules with css-loader, and this project will make it work.

in

.test1 {
    animation: 3s linear 1s demo1;
    width: 100px;
    height: 100px;
    background-color: red;
}

@keyframes demo1 {
    from {
        transform: translateX(0px);
    }
    to {
        transform: translateX(300px);
    }
}

out

._SLSqn_M6Y6lv44JVeE6 {
  animation: 3s 1s linear demo1;
  width: 100px;
  height: 100px;
  background-color: red;
}
@keyframes demo1 {
  from {
    transform: translateX(0px);
  }
  to {
    transform: translateX(300px);
  }
}

how

use as a loader

// ...
const WebpackCssModuleEscaper = require('css-modules-escaper');

module.exports = {
    // ...
    module: {
        rules: [
            {
                test: /\.less$/i,
                use: [
                    'style-loader',
                    MiniCssExtractPlugin.loader,
                    {
                        loader: 'css-loader',
                        options: {
                            esModule: false,
                            modules: {
                                localIdentName: '[hash:base64]',
                                getLocalIdent: (context, localIdentName, localName) => {
                                    return null;
                                }
                            }
                        }
                    },
                    // add escaper loader
                    'css-modules-escaper',
                    'less-loader',
                ],
            },
        ]
    },
    plugins: [
        // add escaper plugin
        new WebpackCssModuleEscaper.plugin(),
        // ...
    ]
}

use as a postcss-plugin

// ...
const WebpackCssModuleEscaper = require('css-modules-escaper');

module.exports = {
    // ...
    module: {
        rules: [
            {
                test: /\.less$/i,
                use: [
                    'style-loader',
                    MiniCssExtractPlugin.loader,
                    {
                        loader: 'css-loader',
                        options: {
                            esModule: false,
                            modules: {
                                localIdentName: '[hash:base64]',
                                getLocalIdent: (context, localIdentName, localName) => {
                                    return null;
                                }
                            }
                        }
                    },
                    {
                        loader: 'postcss-loader',
                        options: {
                            postcssOptions: {
                                plugins: [
                                    require.resolve('css-modules-escaper/src/postcss-plugin')
                                ],
                            },
                        },
                    },
                    'less-loader',
                ],
            },
        ]
    },
    plugins: [
        new WebpackCssModuleEscaper.plugin(),
        // ...
    ]
}

Keywords

FAQs

Last updated on 23 Sep 2021

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc