npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wrapper-css-loader

v1.1.3

Published

webpack loader for react component wrapper css class

Downloads

13

Readme

wrapper-css-loader

把css内容加载对象并且用md5值做为外壳包装原有全部class,一般和postcss配合使用。 如:

{
    test: /\.css$/,
    loader: 'wrapper-css-loader?length=4!postcss-loader'
}

处理结果

// 导入样式
import css from './style.css'

/*
css 值如下
{
    wrapper: '9033df94d33a368c3b73',
    css: '.9033df94d33a368c3b73 .component { color: blue }'
}
*/

例子说明

使用前

.component {
    color: blue
}

使用后

.9033df94d33a368c3b73 .component {
    color: blue
}

参数设置

length

wrapper-css-loader?length=4

length 设置包装class名字的长度, 结果是 .9033 .component

wrapper

wrapper-css-loader?wrapper=true // 外面用class包装,适用于组件样式
wrapper-css-loader?wrapper=false // 外面不用包装,适用于全局样式
// 可以这样处理全局样式,把css扩展名特殊化,例如: .css -> .gcss 
{
    test: /\.gcss$/,
    loader: 'wrapper-css-loader?length=3&wrapper=false!postcss-loader'
}

注意

  • length 必须大于1
  • 在css文件中不能使用 @import [在postcss中加入postcss-import插件可以支持]
  • css文本处理时候会自动把单引号处理成双引号'' -> ""