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

condition-filter-loader

v1.1.2

Published

1. This plugin serves as a connecting link between the preceding and the following 2. There is a filtering function during loader execution 3. When a plugin needs to be executed under certain conditions, but it has no filter conditions, you can us

Downloads

1

Readme

condition-filter-loader

purpose

1. This plugin serves as a connecting link between the preceding and the following
2. There is a filtering function during loader execution
3. When a plugin needs to be executed under certain conditions, but it has no filter conditions, you can use this plugin

options

1. config.projectPath
    1. project root dir
        1. 项目根目录
    2. The user-defined directory can be implemented. In principle, it can not be specified, because it will be obtained from the running direc
        1. 可以让你自定义项目目录,但是原则上不需要的,因为会到运行目录下去获取
    3. This parameter is mainly used to execute loader 
        1. 这个参数的目的主要为了执行loader
2. config.loader
    1. Subsequent loaders to be converted
        1. 后续需要转换的loader
    2. this parameter is required
        1. 这个参数是必须的
3. config.include
    1. Conditions to include,When the condition is successful, the subsequent conversion loader will not be executed
        1. 需要包含的条件,如果条件成功了筛选成功了不会执行后续条件
    2. Can be string, regular, array, array must be string, regular. The string must be a path
        1. 可以是字符串,正则,数组,数组中必须是字符串,正则. 字符串必须是路径
4. config.exclude
    1. Conditions to be excluded ,When the condition is successful, the subsequent conversion loader will not be executed
        1. 需要包含的条件,如果条件成功了筛选成功了不会执行后续条件
    1. Can be string, regular, array, array must be string, regular. The string must be a path
        1. 可以是字符串,正则,数组,数组中必须是字符串,正则. 字符串必须是路径
5. config.loaderPath
    1. Relying on loader to make directory 
        1. 依赖loader所在的目录
    2. default value be project root dir + node_modules
        1. 默认值是项目根目录/node_modules
6. other config
    1. The parameters required by the conversion plugin can be written in this location,look example for
        1. 转换插件需要的参数可以写在这个。看如下实例

install

    1. npm install condition-filter-loader -D
    2. yarn add condition-filter-loader -D

example for

1. Business scenario: meet the requirement that image compression is not performed under one path, and image compression is performed for others
2. 业务场景:满足某个路径下不执行图片压缩,其他的执行图片压缩

webpack.config.js

{
    test: /\.(png|jpe?g|gif|webp)(\?.*)?$/
    use: [
        {
            loader: "url-loader",
            options: {
                limit: 4096,
            },
        },
        {
            loader: 'condition-filter-loader',
            options: {
                config: {
                    loader: “image-webpack-loader”,
                    // When the condition < exclude > is met, you do not want to execute image webpack loader 
                    // 满足条件<exclude>的时候,不想执行image-webpack-loader
                    exclude: path.resolve(__dirname, 'src/assets/img/graph')
                },
                // The following are the parameters required to convert the loader itself
                // 以下是转换loader本身需要参数
                mozjpeg: {
                  progressive: true,
                  quality: 50
                },
                optipng: {
                  enabled: false
                },
                pngquant: {
                  quality: [0.65, 0.9],
                  speed: 4
                },
                gifsicle: {
                  interlaced: false
                },
                webp: {
                  quality: 75
                },
                bypassOnDebug: true
            }
        }
    ]
}

vue.config.js

chainWebpack: (config) => {
    config.module
      .rule('images')
      .use('condition-filter-loader')
      .after('url-loader')
      .loader("condition-filter-loader")
      .options({
        config: {
            exclude: path.resolve(__dirname, 'src/assets/img/graph'),
            loader: 'image-webpack-loader',
        },
        mozjpeg: {
          progressive: true,
          quality: 50
        },
        optipng: {
          enabled: false
        },
        pngquant: {
          quality: [0.65, 0.9],
          speed: 4
        },
        gifsicle: {
          interlaced: false
        },
        webp: {
          quality: 75
        },
        bypassOnDebug: true
      })
}

Contact me

Github