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

@snacking/pretreat

v1.0.0

Published

根据约定的结构配置,进行资源预处理...

Downloads

4

Readme

@snacking/pretreat 使用指南

说明

基于gulp开发,目的是,只要配置好资源路径,执行命令就能进行资源预处理...

全局安装

npm install @snacking/pretreat -g

查看版本号

sn-pr -v

准备配置文件

sn-pr init

将得到配置文件示例pretreat.json,该文件里做了较为详细的配置说明...

主要是设置需要执行什么任务,资源源路径,输出路径,是否压缩等等...

本工具会依据该配置进行资源预处理...

目前支持:

  • less编译成css,以及合并、压缩
  • css的合并、压缩
  • js的合并、压缩,支持babel转换
  • html的合并、压缩
  • json的合并、压缩,属性值支持js函数
  • 图像的压缩
  • 各类资源的复制

例子

1、在当前目录里,将js做压缩并输出,并且使用babel转换

{
  "projects": [
    {
      "js": {
        "useBabel": true,
        "paths": [
          {
            "source": "./",
            "minify": true
          }
        ]
      }
    }
  ]
}

2、将当前目录的js及其压缩文件输出到dist目录

{
    "output": "./dist",
    "projects": [
        {
            "js": {
                "paths": [
                    {
                        "source": "./",
                        "minify": true
                    }
                ]
            }
        }
    ]
}

3、需要处理的资源在不同的工程中:./demo_1 ./demo_2

{
    "projects": [
        {
            "name": "demo_1"
            "js": {
                "paths": [
                    {
                        "source": "",
                        "minify": true
                    }
                ]
            }
        },
        {
            "name": "demo_2"
            "js": {
                "paths": [
                    {
                        "source": "",
                        "minify": true
                    }
                ]
            }
        }
    ]
}

4、需要处理的资源有较长的公共目录:./demo_1/src

{
    "projects": [
        {
            "base": "./demo/src",
            "js": {
                "paths": [
                    {
                        "source": "",
                        "minify": true
                    }
                ]
            }
        }
    ]
}

执行预处理

sn-pr

选项

该命令有4个选项...

-clr --clear [path]            指定预处理前需要清空的目录,默认不清空任何目录
-cfg --config [fileName]       指定配置文件名称,默认使用pretreat.json
-w --watch [open]              是否开启监听,默认不监听
-pn --pName [projectName]      指定项目名处理,如果在配置文件里设置了项目名称,默认全部处理

例子

sn-pr -clr ./dist/**/*.*       预处理前清空dist目录下所有文件
sn-pr -cfg example.json        把example.json作为配置文件
sn-pr -w true                  开启监听
sn-pr -pn demo                 仅处理demo项目里的任务

使用多个选项...

sn-pr -clr ./dist/**/*.* -cfg example.json

如果不需要选项里的内容,且配置文件名为pretreat.json,执行

sn-pr

即可...