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

koa-combo-parse

v0.2.3

Published

简单的koa模块, 解析combo的url.

Downloads

20

Readme

koa-combo-parse

一个简单的koa中间件, 用于解析combo的url.

安装

npm install koa-combo-parse --save

例子

const path = require('path');
const app = require('koa')();
const comboParse = require('koa-combo-parse');

app.use(comboParse({
    miniCSS: true,
    base: path.resolve(__dirname, './htdocs')
}));

参数说明

miniCSS(boolean)

标识是否压缩CSS, 默认为false.

提供两种方式标识是否压缩CSS

全局设置miniCSS之后,会忽略_mcss的值. 若压缩出现异常, 则会返回未压缩的代码

  1. 初始化插件的时候设置miniCSStrue, 则所有combo的css都会压缩之后输出到客户端
  2. 单个combo的url中增加_mcss字段,设置为truey, 则该url对应的文件压缩后输出

例:

// 第一种情况(两个URL中解析出的CSS, 均会做压缩处理)
http://www.ooxx.com/??a.css,b.css&_mcss=true
http://www.ooxx.com/??a.css,b.css

// 第二种情况(前两个URL解析出的CSS会做压缩处理)
http://www.ooxx.com/??a.css,b.css&_mcss=true
http://www.ooxx.com/??a.css,b.css&_mcss=y
http://www.ooxx.com/??a.css,b.css&_mcss=1
http://www.ooxx.com/??a.css,b.css

base(string)

静态资源根目录(解析结果会拼接该目录和pathname作为文件所在目录)

解析规则

以上方demo中的配置为例

目标URL: http://www.ooxx.com/js/lib/??a.js,b.js,c.js

path.resolve(__dirname, './htdocs') => /home/ooxx/www/htdocs

/home/ooxx/www/htdocs/js/lib/a.js
/home/ooxx/www/htdocs/js/lib/b.js
/home/ooxx/www/htdocs/js/lib/c.js

url中只会获取?开头的数据, 即http://www.ooxx.com/js/lib/??a.js,b.js,c.js&_=12323&后的数据会被抛弃(使用过程中, 应避免在query里出现多个以?开头的数据)

DEBUG

DEBUG=koa-combo-parse