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

miniprogram-dayjs-copy

v1.0.0

Published

按需引入dayjs插件

Downloads

1

Readme

miniprogram-dayjs-copy

演示如何使用编译前预处理按需引入dayjs的插件,请确保使用本工具前已安装 dayjs,并已执行构建 NPM。 引入插件的方式有很多种,不一定非要使用哪一种,可以的话,请考虑直接下载插件对应js文件到项目中直接引入也是可以的。

开始

npm install -D miniprogram-dayjs-copy

package.json中添加配置:

{
  "scripts": {
    "prebuild": "cdp"
  }
}

增加插件配置

本工具在package.json中支持如下配置:

{
  config: {
    "miniprogram-dayjs-copy": {
      miniprogram_npm: "miniprogram_npm路径,例如./miniprogram_npm,可缺省",
      node_modules: "node_modules路径,例如./node_modules,可缺省",
      esm: true, // 是否使用 dayjs/esm 中js,true为使用
      plugins: ["plugin/advancedFormat", "locale/zh", "locale/en"],
    },
  },
}

使用自定义预处理命令

在下方的编译前预处理中根据工作路径与package.json位置添加如下内容:

npm run prebuild

手动运行编译

DEMO

DEMO见本仓库中example文件夹,克隆本项目后,使用微信开发者工具导入example。随后执行:

cd miniprogram
npm install

注意事项

请确保本工具是作为devDependencies被引入,避免被打包。

原理

使用编译前预处理执行 Shell 拷贝相关插件

缺陷

  • 每次新增插件配置需要手动执行编译,比较繁琐,自动编译不会自动执行编译前预处理。但是一般不会经常修改配置。
  • 暂不支持自动移除未引入插件,对于以前引入过之后不再需要的插件需要手动删除。
  • 微信开发者工具的清除编译缓存可能不是很奏效,有些时候你需要重启开发者工具,比如一些手动删除导致的引入错误。

相关文档