8 Star 22 Fork 5

小弟调调 / sgo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

English

sgo logo

Build & Deploy Issue Forks Stars Releases npm version

用于快速原型设计的开发服务。它提供了一个简洁的界面,用于列出目录的内容并切换到子文件夹,以当前目录为根目录快速起一个静态服务。

此外,它在提供静态站点方面也很棒。 如果目录包含 index.html ,则serve将自动呈现它而不是提供目录内容,并将任何 .html 文件作为呈现页面而不是文件内容作为明文提供。

更名: ssr => sgo
sgo: Server Go 的缩写

⚠️ ssr 已经捐赠给阿里某团队。

特征

🗂 提供目录中的脚本,样式,图像等静态内容。
🖥 将所有非文件请求(如// admin)重新路由到单个文件。
♻️ 添加,删除或修改项目文件时重新加载浏览器。
📚 可读的 TypeScript 源代码,鼓励学习和贡献。
💥 删除冗余的 proxy 功能, 代理功能请使用 mocker-api
⚛️ 支持预览 React/Vue/Angular 项目的静态页面。


快速开始

使用 npm i sgo -D 添加 sgo 作为 dev 依赖项或直接从终端运行:

npm install -g sgo # 全局安装 sgo
sgo # 创建一个服务
# 或者
npx sgo [--port] [--dir]

命令帮助

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     The file served for all non-file requests.
                                                          [string] [default: ""]
  --help         Show help                                             [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  The file served for all non-file requests..
  $ sgo -p 2019                    Designated port.
  $ sgo -d node_modules/dir        Specified directory "node_modules/dir".

Copyright 2019

在项目的 package.json 文件中使用 npm 脚本的示例:

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

在 Node.js 中使用

const sgo = require('sgo');

// Create server
sgo.default({ port: 1987, dir: '' });
import server from 'sgo';

// Create server
server({ port: 1987, dir: '' });

License

MIT © Kenny Wong

MIT License Copyright (c) 2020 小弟调调™ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

将任意一个目录设置成一个静态服务器,用于快速原型设计的开发服务器。 将目录设置为静态服务器。它提供了404整洁的界面,用于列出目录的内容并切换到子文件夹。 展开 收起
TypeScript 等 3 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
TypeScript
1
https://gitee.com/jaywcjlove/sgo.git
git@gitee.com:jaywcjlove/sgo.git
jaywcjlove
sgo
sgo
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891