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

@yocdev/loom

v1.2.1

Published

应用于小程序的自动生成路由配置文件、类型文件,处理 icon 的自动化工具

Downloads

18

Readme

loom

应用于小程序的自动生成路由配置文件、类型文件,处理 icon 的自动化工具

使用

下载

npm install @yocdev/loom --dev
// 或者
yarn add @yocdev/loom --dev

使用

在根目录下添加配置文件 loom.config.ts

示例

import { defineConfig } from '@yocdev/loom';

export default defineConfig({
  // 路由处理配置文件
  router: {
    // 扫瞄文件
    include: ['src/**/pages/*/index.ts[x]'],
    exclude: [],
    // 产物输出地址
    output: 'src/__generated__/router',
    transformPageInfo(pageInfo) {
      const { folderPath } = pageInfo;

      return {
        ...pageInfo,
        folderPath: folderPath.replace('src/', '') + '/index',
      };
    },
    transformRouterJson(routerJson) {
      const { pageTypeMapping } = routerJson;

      const subPackagePaths: string[] = [];

      const routerSource = Object.keys(pageTypeMapping).reduce((res, key) => {
        const { folderPath } = pageTypeMapping[key];
        const isSubPackagePage = folderPath.includes('package');

        if (isSubPackagePage) {
          subPackagePaths.push(folderPath);
          return res;
        }
        return {
          ...res,
          [key]: folderPath,
        };
      }, {});

      const packageMapping = subPackagePaths.reduce((res, path) => {
        const packageName = path.match(/(package\w+)/)?.[1] || '';
        const relationPath = path.match(/package\w+\/([\S]*)/)?.[1] || '';

        const originPackageInfo = res[packageName] || {
          root: packageName,
          name: packageName,
          pages: [],
        };

        originPackageInfo.pages.push(relationPath);

        return {
          ...res,
          [packageName]: originPackageInfo,
        };
      }, {});

      return {
        ...routerJson,
        routerSource,
        subpackages: Object.values(packageMapping),
      };
    },
  },
  icon: [
    {
      include: ['src/assets/icons/*.svg'],
      exclude: [],
      filePrefix: 'Icon',
      output: 'src/__generated__/icons',
    },
    {
      include: ['src/assets/svgs/*.svg'],
      exclude: [],
      filePrefix: 'Svg',
      output: 'src/__generated__/svgs',
    },
  ],
});

项目中的设置约定

给对应页面配置 route.config.ts 配置示例

export const pageName = '页面标题';

// 页面 id,可以页面埋点标识
export const pageId = '1';

// 页面入参
export interface PageParams {
  name: string;
}

常见问题处理

sharp 安装时需要

npm config set sharp_binary_host "https://npmmirror.com/mirrors/sharp"
npm config set sharp_libvips_binary_host "https://npmmirror.com/mirrors/sharp-libvips"
npm install sharp