【前言】
live-server是可以運行前端靜態文件的一個服務器,既然我們要前后端分離,所以就需要單獨將html代碼運行起來,這里我們選擇live-server,等到后邊真正部署的時候在用nginx
在寫一下簡單的項目或學習一些技術的練習,沒有服務器的話,每次寫的代碼都需要手動刷新瀏覽器。有點無奈,但是如果你安裝了這個live-server
服務器就可以不用手動刷新,實時預覽自己寫的代碼了。live-server是一個具有實時重載功能的小型開發服務器。用它來熱加載HTML / JavaScript / CSS文件,但不能用於部署最終的網站系統。
【主體】
--port=NUMBER - select port to use, default: PORT env var or 8080 --host=ADDRESS - select host address to bind to, default: IP env var or 0.0.0.0 (“any address”) --no-browser - suppress automatic web browser launching --browser=BROWSER - specify browser to use instead of system default --quiet | -q - suppress logging --verbose | -V - more logging (logs all requests, shows all listening IPv4 interfaces, etc.) --open=PATH - launch browser to PATH instead of server root --watch=PATH - comma-separated string of paths to exclusively watch for changes (default: watch everything) --ignore=PATH - comma-separated string of paths to ignore (anymatch-compatible definition) --ignorePattern=RGXP - Regular expression of files to ignore (ie .*\.jade) (DEPRECATED in favor of --ignore) --middleware=PATH - path to .js file exporting a middleware function to add; can be a name without path nor extension to reference bundled middlewares in middleware folder --entry-file=PATH - serve this file (server root relative) in place of missing files (useful for single page apps) --mount=ROUTE:PATH - serve the paths contents under the defined route (multiple definitions possible) --spa - translate requests from /abc to /#/abc (handy for Single Page Apps) --wait=MILLISECONDS - (default 100ms) wait for all changes, before reloading --htpasswd=PATH - Enables http-auth expecting htpasswd file located at PATH --cors - Enables CORS for any origin (reflects request origin, requests with credentials are supported) --https=PATH - PATH to a HTTPS configuration module --proxy=ROUTE:URL - proxy all requests for ROUTE to URL --help | -h - display terse usage hint and exit --version | -v - display version and exit
package name: (0710) demo version: (1.0.0) description: live-server的練習 entry point: (index.js) test command: git repository: keywords: author: 猿來獨往 license: (ISC) About to write to D:\GitHub_Repository\Clone_Files\vue-study\0710\package.json: { "name": "demo", "version": "1.0.0", "description": "live-server的練習", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "猿來獨往", "license": "ISC" } Is this OK? (yes)
.