@lzwme/sserver
TypeScript icon, indicating that this package has built-in type declarations

0.0.8 • Public • Published

@lzwme/sserver

@lzwme/sserver

NPM version node version npm download GitHub issues GitHub forks GitHub stars

一个基于 Node.js 的简易静态服务器,用于辅助开发调试随启随用。

# 快速启动一个静态服务器
npx @lzwme/sserver -d ./dist

安装

# 全局安装
npm i -g @lzwme/sserver
ss -h

# 或者在项目中安装
npm i -D @lzwme/sserver
npm exec ss -- -h

# 或者直接使用 `npx`
npx @lzwme/sserver -h

使用

示例:

# 以当前目录下的 dist 作为静态根目录
ss -d ./dist

# 启用 https
ss --https

# 启用 https,指定域名(默认为 localhost)
ss -H --host local.lzw.me

# 启用 https,并保存默认生成的 ssl 证书
ss -H --ssl-cache ./cache

配置代理转发

支持通过配置文件 ss.config.js 指定代理转发等详细配置规则。

# 在当前目录初始化一个 ss.config.js 配置文件
ss init

配置文件内容示例:

// ss.config.js

/** @type {import('@lzwme/sserver').SSConfig} */
module.exports = {
  port: 8888,
  https: false,
  sslCache: '',
  rootDir: '.',
  // 代理转发配置
  proxyConfig: [
    // 内网代理企业微信机器人接口示例
    {
      api: '/proxy/cgi-bin/webhook/send',
      config: {
        target: 'https://qyapi.weixin.qq.com',
        changeOrigin: true,
        pathRewrite: {
          '^/proxy/cgi-bin': '/cgi-bin',
        },
      },
    },
  ],
}

开发

本地二次开发:

git clone https://github.com/lzwme/static-server.git
pnpm install
pnpm build

# dev
pnpm dev

# global link
npm link

或者 fork 本项目进行代码贡献。

欢迎贡献想法与代码。

License

@lzwme/sserver is released under the MIT license.

该插件由志文工作室开发和维护。

Package Sidebar

Install

npm i @lzwme/sserver

Weekly Downloads

0

Version

0.0.8

License

MIT

Unpacked Size

39.7 kB

Total Files

27

Last publish

Collaborators

  • renxia001
  • renxia