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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@canvases/ifcomp-config-loader

v1.0.0

Published

本项目提供了一个 Webpack Loader,用于在 Vue2 项目中进行条件编译功能。它允许你在 Web 和不同平台(如 `APP-PLUS`、`H5`、`MP-WEIXIN` 等)之间运用不同的业务组件。

Readme

README: UniApp 条件编译 Loader for Webpack + Vue2

本项目提供了一个 Webpack Loader,用于在 Vue2 项目中进行条件编译功能。它允许你在 Web 和不同平台(如 APP-PLUSH5MP-WEIXIN 等)之间运用不同的业务组件。


📌 功能特点

支持 #ifcomp 条件编译,根据 platform 变量选择代码块。 ✅ 适用于 Webpack + Vue2 项目,可在运行打包时自动处理条件编译。


📂 使用示例

在 Vue2 组件或 JavaScript 代码中,你可以使用条件编译语法:

// #ifcomp  hellowrod
console.log('This is for hellowrod component');
// #endif

⚙ 安装与配置

1️⃣ 安装 Loader

你可以直接在项目中创建 conditional-loader.js,或者发布为 npm 包后安装:

npm install your-loader-name

2️⃣ 配置 Webpack

webpack.config.js 中添加 Loader 配置:

module.exports = {
  module: {
    rules: [
      {
        test: /\.js$/,
        use:{
            loader: './plugins/module-condition-loader.js',
            options: { platform: process.env.PLATFORM,
                entryJson: path.resolve(__dirname, 'manifest.json')
            } // 注入环境变量
        }
      }
    ]
  }
};

package.json 中添加不同平台的构建命令:

"scripts": {
  "build:h5": "cross-env PLATFORM=H5 webpack --mode production",
  "build:app": "cross-env PLATFORM=APP-PLUS webpack --mode production",
  "build:wx": "cross-env PLATFORM=MP-WEIXIN webpack --mode production"
}

🛠 实现原理

详细规则和渲染逻辑可见源代码。


🌟 结论

这个 Webpack Loader ,在 Vue2 + Webpack 项目里使用 #ifcomp 条件编译 使用不同的组件,自动删除无关代码,使打包后的文件更小、更简洁。

🚀 让你的 Vue2 项目支持多平台代码分支,轻松适配不同端!