staticky是一个更好的、更简单的静态文件服务器。你能使用它然后可以在电脑或手机上查看静态文件。并且当文件发生变化时能自动刷新浏览器。
怎么使用
首先你可以先执行 npm install staticky -g 命令,
然后打开你的项目目录,使用命令 staticky,
它能自然帮你打开浏览器显示index.html,
如果 index.html 文件不存在,则它将你的项目目录下的所有文件展示出来。
用法
在项目的目录中使用 staticky 命令。或者,您可以添加作为命令行参数的路径。
命令行参数:
-por--port端口使用,默认8091-nor--no-browser是否自动打开浏览器-tor--target选择打开哪个文件,默认index.html-dor--dir选择工作目录,默认process.cwd-gor--gzip是否开启gize压缩-ror--reload观察文件或目录的变化,自动刷新。默认选择target file,只有两个选项target或者dir-hor--help打印用法
示例
staticky -p 8000 // start static file server in port 8000
staticky -n // not open browser automatically
staticky -t index.js // the index.js file will be opened
staticky -d src // the src directory under the current directory will be working directory
staticky -g // open gizp encoding
staticky -r dir // all files in the current directory will be monitored.