怎样启动本地服务

作者: 小贤笔记 | 来源:发表于2018-06-29 10:49 被阅读12次
    • 全局安装 http-server
      npm install http-server -g
    • 打包 - 生成 dist 文件夹
      npm run build
    • 进入 dist 文件夹
      http-server
    • 访问
    • package.json 设置
     "scripts": {
         "start": "http-server -a 0.0.0.0 -p 8000",
     }
    
    • 参数

      • -p 端口号 (默认 8080)

      • -a IP 地址 (默认 0.0.0.0)

      • -d 显示目录列表 (默认 'True')

      • -i 显示 autoIndex (默认 'True')

      • -e--ext 如果没有提供默认的文件扩展名(默认 'html')

      • -s--silent 禁止日志信息输出

      • --cors 启用 CORS via the Access-Control-Allow-Origin header

      • -o 在开始服务后打开浏览器

      • -c 为 cache-control max-age header 设置Cache time(秒) , e.g. -c10 for 10 seconds (defaults to '3600'). 禁用 caching, 则使用 -c-1

      • -U--utc 使用UTC time 格式化log消息

      • -P--proxy 代理

      • -S--ssl 启用 https

      • -C--cert ssl cert 文件路径 (default: cert.pem)

      • -K--key Path to ssl key file (default: key.pem).

      • -r--robots

      • -h--help 打印以上列表并退出

    相关文章

      网友评论

        本文标题:怎样启动本地服务

        本文链接:https://www.haomeiwen.com/subject/qguyyftx.html