Movatterモバイル変換


[0]ホーム

URL:


简体中文sgorust

sgo logo

Build & DeployIssueForksStarsReleasesnpm version

A dev server for rapid prototyping. It provides a neat interface for listing the directory's contents and switching into sub folders.

In addition, it's also awesome when it comes to serving static sites. If a directory contains an index.html, serve will automatically render it instead of serving directory contents, and will serve any .html file as a rendered page instead of file's content as plaintext.

Rename:ssr =>sgo
sgo:Server Go

⚠️ssr package has been donated to a certainteam in Ali.

Features

🗂 Serve static content like scripts, styles, images from a directory.
🖥 Reroute all non-file requests like/ or/admin to a single file.
♻️ Reload the browser when project files get added, removed or modified.
📚 Readable source code that encourages learning and contribution.
💥 Remove the redundancyproxy feature, Please usemocker-api.
⚛️ Preview the static page of the React/Vue/Angular project.


Quick Start

Add sgo as a dev dependency usingnpm i sgo -D or run directly from the terminal:

npminstall-g sgo# install sgosgo# Create server# ornpx sgo[--port][--dir]

Command help

Usage: sgo[options]Options:--version      Show version number[boolean]  --port,-p     Set the port.[number][default:1987]  --reload-port  Set the reload port.[number][default:19872]  --reload,-r   browser from reloading when files change.[boolean][default: true]  --dir,-d      Specified directory.[string][default:""]  --browser,-b  Browser from opening when the server starts.[boolean][default: true]--fallback     Thefile servedfor all non-file requests.[string][default:""]--help         Showhelp[boolean]Examples:  $ sgo                            Start a dev server.  $ sgo --no-browser               Prevents the browser from opening when the                                   server starts.  $ sgo --no-reload                prevents the browser from reloading when                                   files change.  $ sgo--fallback dir/index.html  Thefile servedfor all non-file requests..  $ sgo-p2019                    Designated port.  $ sgo-d node_modules/dir        Specified directory"node_modules/dir".Copyright2019

Example usage with npm scripts in a project's package.json file:

{"scripts":{"start":"npx sgo -p 2019"}}

Used in Node.js

const sgo=require('sgo');// Create serversgo.default({port:1987,dir:''});
importserverfrom'sgo';// Create serverserver({port:1987,dir:''});

License

MIT ©Kenny Wong


[8]ページ先頭

©2009-2025 Movatter.jp