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

umi-plugin-proxy

v1.0.1

Published

Resource proxy function, you can point online resources to local resources, support https and solve combob

Downloads

8

Readme

umi-plugin-proxy

NPM version NPM downloads

Resource proxy function, you can point online resources to local resources, support https and solve combob

资源代理功能,可以将线上资源有规则指向本地资源,支持https和解commob能力

Usage

Configure in .umirc.js,

export default {
  plugins: [["umi-plugin-proxy", options]]
};

rewrite

将请求的资源映射到特定的 url,比如可以把线上的 js,css 映射到本地 webpack dev server 对应的文件或者本地文件,配置规则如下, rule 是需要匹配的正则表达式,dest 是映射后的 url,通过$n 来引用 rule 中正则匹配到的部分

{
  enable: true,
  proxy: {
    // 例如 
    // 匹配 /trip/titan/1.0.0/umi.js -> https://127.0.0.1:7000/umi.js
    rewrite: [{
      rule: /trip\/titan\/([\d\.]*)\/(.*).js/,
      dest: 'https://127.0.0.1:7000/$2.js'
    }, {
      rule: /trip\/titan\/([\d\.]*)\/(.*)\.css/,
      dest: 'https://127.0.0.1:7000/$2.css'
    }]
  }
}

forward

把 combo 的多个线上的 url 解 combo 后代理到目标地址,类似 rewrite,不同的是可以处理 combo 的文件

proxy: {
  forward: [
    {
      project: "trip/titan", // 格式为:${group}/${repo}
      dest: "http://127.0.0.1:7000/"
    }
  ];
}

证书认证

添加 umi cert 命令可以认证本地的 https 证书

$ umi cert

HTTPS

  1. 需要将anyproxy生成的CA认证,放入到系统钥匙串中,系统
$ umi cert
证书安装完成
detecting CA status...
AnyProxy CA exists, but not be trusted
? Would you like to open the folder and trust it ? Yes
  1. umi cert运行后同时将在根目录生成 2 个 pem 文件
project  
│   .umirc.js
│   localhost+2-key.pem
│   localhost+2.pem
│   package.json
  1. 在根目录修改.env文件,填写CERTKEY文件目录
HTTPS=true
CERT=./localhost+2.pem
KEY=./localhost+2-key.pem
# PORT=7000
# SOCKET_SERVER=https://127.0.0.1:7000
  1. 完成 重新编译即可
$ umi dev

LICENSE

MIT