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

mini-optimizer

v1.0.3-beta.7

Published

小程序包大小优化工具

Downloads

38

Readme

Optimizer

小程序包大小优化工具

基本能力

移动(拷贝)子包依赖到子包目录中

对于多子包依赖的相同文件,一般会放在主包中,导致主包会包含并不依赖的文件,包体积变大

如何使用

npm install mini-optimizer -D

命令行

Usage: optimize <path> [options]

Options:
  -t, --type <type>                     type of mini app wx or my (default: "wx")
  -c, --config <path>                   path to config file (default: "./optimizer.config.json")
  -o, --output <path to fold>           redirect output to the fold
  --remove-useless-file                 remove useless file
  --minify-css                          minify css
  --minify-js                           minify js
  --minify-xs                           minify xs (.sjs|.wxs)
  --minify-xml                          minify xml
  --minify-json                         minify json
  --rename-file                         rename file
  --renamed-files-map <file path>       write renamed file map to the file (default: "./renamed-files-map.json")
  --rename-component                    rename component
  --renamed-components-map <file path>  write renamed component map to the file (default: "./renamed-components-map.json")
  -h, --help                            display help for command

配置

{
  "renameFile": true,
  "renameComponent": true,
  "minifyJs": true,
  "minifyCss": true,
  "minifyXs": true,
  "minifyXml": true,
  "minifyJson": true,
  "removeUselessFile": true,
  "uselessExculde": [
    "assets/**/*.*"
  ],
  "renameExculde": [
    "assets/images/dish-default.png"
  ],
  "plugins": ["mini-optimizer/lib/plugins/merge-import"],
  "output": "./source-d"
}

renameFile

重命名文件,即:把目录结构打平并且缩短文件名的长度

文件路径会被包含在JS中,引用的文件路径越长包体积越大

renameComponent

重命名组件, 即:把组件名称替换为更短的名称

为了XML语义化,在开发时会使用语义化的标签名,比如user-info, 这样会增加xml的大小,使用更短的组件名降低包体积。

minifyJs

压缩JS体积

minifyXs

压缩.wxs.sjs体积

minifyCss

压缩CSS体积

minifyXml

压缩XML体积

minifyJSON

压缩JSON体积

removeUselessFile

移除无用文件

uselessExculde

保留的文件 支持glob

renameExculde

不重命名的文件 支持glob

output

输出的文件夹

插件

merge-import

JS文件依赖越多包体积越大,所有通过合并import可以有效减小包体积

- import Event from '../../common/base/event';
- import System from '../../common/utils/system';
- import { getId } from '../../lib/bizdata';
+ import { b_ as Event, c5 as System, R as getId } from "./__entry__";