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

@haici/taro-inject-loader

v1.0.2

Published

海鹚 taro 全局组件注入工具

Downloads

3

Readme

@haici/taro-inject-loader

海鹚 taro 全局组件注入工具

背景

taro 小程序目前每一个页面的 page 是独立的,如果我们有通用的功能性组件想要在页面中使用,或者有通用的布局想要应用到全局页面,只能在每个页面中手动import,使用 taro-inject-loader 可以帮助我们自动注入我们想要注入的通用组件。

使用方式

项目配置

在实际 taro 项目中使用时,使用方式示例如下:

// 一般来说配置文件路径:config/index.js

constant isPage = () => {
  return ...
}

export default {
  ...
  mini: {
    webpackChain(chain) {
      chain.merge({
        module: {
          rule: {
            injectBaseComponentLoader: {
              test: /\.[tj]sx$/,
              use: [
                {
                  loader: '@haici/taro-inject-loader',
                  options: {
                    importPath: '@/components/layout/pageContainer/index',
                    injectType: 'wrap',
                    isPage,
                  },
                },
              ],
            },
          },
        },
      });
    },
  }
  ...
}

参数说明

在配置文件中使用时,options 具体参数说明: | 参数名 | 类型 | 必填 | 枚举值 | 默认值 | 说明 | | :-----| :---- | :---- | :---- | :---- | :---- | | importPath | String | 是 | - | - | 需要注入到全局页面的通用组件文件路径 | | injectType | String | 否 | wrap | append | append | 注入的方式,wrap 为包含模式,append 为子节点模式 | | isPage | Function | 否 | - | 内置默认判断函数 | 判断是否是页面的方法,返回一个布尔值 |