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

front-server

v0.5.1

Published

front-end dev server, use nginx style configuration

Downloads

2

Readme

front-server

用于开发环境的简单前端HTTP静态文件和反向代理服务器,支持Nginx风格的配置文件,便于嵌入与后端分离的前端工程,该项目主要用于学习研究,请勿用于生产环境或关键服务

配置示例

listen 3000;
auto_refresh on;

location ~ ^/web/ {
  alias /www/html/;
}

location ~ ^/(api|upload) {
  proxy_pass http://192.168.1.50:8080;
}

location ~ ^/test {
  proxy_set_header Host www.example.com;
  proxy_pass http://192.168.1.80;
}

location / {
  root dist;
  try_files $uri $uri/ /index.html;
}

本地安装使用

npm i front-server --save-dev

在工程根目录添加配置文件,配置格式参考示例,命名为 server.conf

package.json 添加 scripts

"scripts": {
  "serve": "node_modules/.bin/front-server server.conf"
}

执行启动命令

npm run serve

全局安装使用

npm i front-server -g

在工程根目录添加配置文件,配置格式参考示例,命名为 server.conf

package.json 添加 scripts

"scripts": {
  "serve": "front-server server.conf"
}

执行启动命令

npm run serve

或者直接通过命令行启动

front-server server.conf

自动刷新

通过设置 auto_refresh on; 可以启用自动刷新功能,该功能监控根目录下的文件变化,然后自动刷新html页面,和hot reload机制并不相同,配置参考如下

listen 3000;
auto_refresh on;

location / {
  root dist; # 根目录dist下的文件变化会受到监控
}

Cookie处理

反向代理会自动清除cookie的domain,并将path置为 /

支持特性

  • listen
  • auto_refresh
  • location
  • root
  • alias
  • try_files
  • proxy_pass
  • proxy_set_header