yp

2.0.3 • Public • Published

支持增量构建的前端静态资源处理工具

Build Status Coverage Status Build status

Code Climate

English version

需要nodejs 4.2以上版本。因为使用了一些v8实现中实验性的es6特性: Proxy等, 在运行时使得node的命令行参数带有**--harmony-proxies**

在windows下暂时输出的map.json文件里面资源名是 \


性能

非增量式:

在一个 Intel(R) Xeon(R) CPU E5-2620 v2 @ 2.10GHz (6 core)机器上,构建一个含有10k+文件的项目,其中包含5k+个需要构建的文件, 初始化构建花费时间平均10.5s,最好9s,最差13s

增量式:

一般耗时秒级

使用说明

1.安装nodejs

需要4.2以上版本

2.安装 pss

npm install -g yp

3.对每个project设置pss.json, 也就是构建的配置文件

{
  "rootPath":"sampleProject",
  "uriConfig": {
    "baseUri":"",
    "protocol":"http://",
    "suffix":"?v=1"
  },
  "ignore":[["^image/fis/article/","/.[^.]+$","^.[^.]+$"],["\\.html$","\\.htm$"]],
  "dir":["image","themes"],
  "mapJsonPath":"demoout/map.json",
  "outdir":"demoout",
  "logdir":"/var/log/pss",
  "logLevel": 0
}

其中各字段: rootPath :项目的根路径,相对于执行pss时的目录, 默认是执行命令时的目录

uriConfig: 生成的json中将包含,为生成url所需的各项配置

ignore:构建中忽略的目录,注意要是正则字符串

dir:需要构建的目录,值得注意的是,不参与构建的将会被原样输出(复制)到outdir

mapJsonPath:存放map.json的路径,如果是绝对路径,则原样输出,如果是相对路径,则是转化为 $rootpath/../$mapJsonPath

outdir:输出目录,将被转化为 $rootPath/../$outdir

logLevel:日志输出级别, 0:info, 1:warning, 2:error ; 默认是0

4.初次构建(从给定的map.json路径读不到文件或者出错时,自动执行)

cd 到指定目录下,执行pss即可

5.增量构建

以管道方式传入需要构建的文件列表即可 例如 svn log | pss

6.构建的输出

将会把新增的文件(image和themes目录)输出到标准输出

示例

dist/image/ar/article/461/banner1.jpg
dist/image/www/1_vbaf8c63.jpg
dist/image/www/tab_language_v8a0bb55.jpg
dist/image/www/css/stylesheet_up_vea48724.css
dist/image/www/css/stylesheet_zong_v0960048.css
dist/map.json

7.注意事项

ulimit -n 需要改大一些,可以是65535

默认的日志路径是 /var/log/pss

示例工程
git clone https://github.com/renaesop/pss.git
cd pss/sample
pss

Package Sidebar

Install

npm i yp

Weekly Downloads

5

Version

2.0.3

License

MIT

Last publish

Collaborators

  • yuji