You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

css-modules-escaper

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css-modules-escaper

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

0.0.3
latest
Source
npmnpm
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
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

postcss

FAQs

Package last updated on 23 Sep 2021

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