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

simple-hot-reload-server

v1.2.0

Published

Set up a server for frontend files & Watch frontend files.

Downloads

1,123

Readme

Simple Hot Reload Server

NPM

中文文档点这

Set up a server for frontend files(html/css/js/favicon) & Watch frontend files.

connected server and client by WebSocket.

Feature

  • Hot Reload

  • Debugger

  • Files View (Easy to open page in root)
    http://localhost:8082/__hrs__/file

  • Source Map Preview

    1. Single
      http://localhost:8082/index.html.hrs.map
      {
          "/Users/moyu/my-code/JavaCode/dike/js/jquery-1.9.1.js": "../../js/jquery-1.9.1.js",
          "/Users/moyu/my-code/JavaCode/dike/js/bootstrap.js": "../../js/bootstrap.js",
          "/Users/moyu/my-code/JavaCode/dike/js/navbar.js": "../../js/navbar.js",
          "/Users/moyu/my-code/JavaCode/dike/css/font-awesome.min.css": "../../css/font-awesome.min.css",
          "/Users/moyu/my-code/JavaCode/dike/css/navbar.css": "../../css/navbar.css",
          "/Users/moyu/my-code/JavaCode/dike/css/conceptModel.css": "../../css/conceptModel.css",
          "/Users/moyu/my-code/JavaCode/dike/css/dropzone/dropzone.css": "../../css/dropzone/dropzone.css"
      }
    2. Total
      http://localhost:8082/__hrs__/map
  • Forward Request
    http://localhost:8082/__hrs__/forward?url=http://blog.moyuyc.xyz/head.jpg

  • Config
    Be Named hrs.config.js on current work directory.

    module.exports = {
        proxy: {
            "/api": {
                target: "http://www.huya.com/longdd",
            },
            "/php": {
                redirect: true, // default: true
                target: "http://localhost:63343/start/static",//"http://localhost:6999",
                changeHost: true,  // default: true
      
                hot: true, // hot reload enable? default: false
                // Function/RegExp: will be set root config hotRule if it is null
                hotRule: function (filename, request) {
                    // console.log(request.url);
                    return /\.(php)$/.test(filename);
                },
                // Function: return local file path
                mapLocal: function (request) {
                    // request: Express Request Object
                    // console.log('mapLocal', request.originalUrl, request.baseUrl, request.url);
                    const url = request.url.replace(/\?[\s\S]*/, '')
                    return "/Users/moyu/my-code/phpCode/start/static" + url;
                },
                // Function/String: return detected directory path
                mapRoot: function (request) {
                    // request: Express Request Object
                    return "/Users/moyu/my-code/phpCode/start/static";
                }
            },
        },
      
        // RegExp or function (filename) {...}
        hotRule: /\.(html|htm)$/, // default: /\.(html|htm)$/
      
        setUp: function (app) {
            /* app is an express server object. */
      
            // http://localhost:8082/test
            app.get('/test', function (req, res) {
                res.end("TEST!");
            });
        }
    };

Install

npm install -g simple-hot-reload-server
Usage: hrs [-p port] path

Options:

  -v --version                get current version.
  -p --port                   set port of server. (default: 8082)
  -c --config                 config path. (default hrs.config.js)
  -h --help                   how to use it.

Others

Support Local Server
Importance: Only support files which filename ends with .html/.htm or is required by html/htm

  1. set up an node server
    hrs path/to/front/root    
  2. open html in address
    http://localhost:8082/where?dubug=true&reload=true
    debug: whether console.log/error/... on browser could print on node server. default: false
    reload: whether reload when file changed. default: true

Support CORS
Importance: support all files (php/jsp/asp...)

  1. set up an node server
    hrs
  2. insert script in HTML manually.
    <script
        src="http://localhost:8082/__hrs__/client-script.js?reload=false&debug=true"
        hrs-local="/Users/moyu/fe-code/a/b/jsonp.html"
        hrs-root="/Users/moyu/fe-code"
    >
    </script>
    hrs-local: map to local html file
    hrs-root: node server detect the directory for hot reload.