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

@onelab/mm

v0.1.1

Published

media-manager

Downloads

19

Readme

Media Manager

安装

yarn add @onelab/mm -D

使用

在项目 package.jsonscripts 中添加:

  "scripts": {
    // ... other scripts
    "mm": "mm"
  },

再在控制台运行 yarn mm,就可以在 mm 配置中的目录下生成 index.js 模块代码,此模块会将 import 自身所在的所有图片并 export 出来。

之后您就可以在自己的组件中从上述模块 import 多个图片

配置

您可以在项目的 package.json 文件添加 mmConfig 对象配置 mm;

您也可以在项目跟目录创建 mmConfig.js 文件并在此文件中配置 mm;

默认项如下:

module.exports = {
  // 需要加载的文件类型
  fileTypes: [".png", ".jpg", ".jpeg", ".svg", ".webp", ".gif"],

  // 需要添加的前缀
  prefix: "",

  // 需要添加的后缀
  suffix: "",
  // 当存在非法开头时(如数字)添加的前缀
  illegalPrefix: "image",

  // 当存在非法开头时如何处理,alert:警告,error 抛错,none:不处理
  logLevel: "alert",

  // 是否遍历子目录
  subdir: true,

  // .svg 格式文件会同时生成
  // import xxx from 'some/dir/xxx.svg'
  // import { componentName as xxx } from 'some/dir/xxx.svg'
  // 两种导入
  // 此配置项设置上述的 componentName
  componentName: "ReactComponent",

  // 上面这些配置项都可以添加到 每个 folder,并权重更高
  // 图片路径文件夹列表
  // 后续更新会支持嵌套
  folders: [
    {
      // path 为必填项
      path: "src/assets/img",
      suffix: "Img",
    },
    {
      path: "src/assets/icon",
      suffix: "Icon",
    },
  ],
};