- 全局安装 http-server
npm install http-server -g - 打包 - 生成 dist 文件夹
npm run build - 进入 dist 文件夹
http-server - 访问
- http://localhost:8080 或 http://127.0.0.1:8080
- package.json 设置
"scripts": {
"start": "http-server -a 0.0.0.0 -p 8000",
}
-
参数
-
-p端口号 (默认 8080) -
-aIP 地址 (默认 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或--certssl cert 文件路径 (default: cert.pem) -
-K或--keyPath to ssl key file (default: key.pem). -
-r或--robots -
-h或--help打印以上列表并退出
-










网友评论