LoginSignup
5
5

More than 5 years have passed since last update.

webpack-dev-server 使用入門

Posted at

當在開發前端的時候,需要一個簡單的 server ,就可以用這個套件

前置作業

首先要有安裝過 node.js 和 npm 套件管理工具

安裝

透過 npm 安裝即可

npm install -g webpack-dev-server

使用

進到專案的根目錄

cd /path/to/project

啟動 server

webpack-dev-server

直接在終端機執行即可

這時候會跳出一段訊息

Hash: 396f0bfb9d565b6f60f0
Version: webpack 1.10.0
Time: 9ms
webpack: bundle is now VALID.
http://localhost:8080/webpack-dev-server/
webpack result is served from /
content is served from /path/to/project

開啟頁面

這時候只要在瀏覽器的網址列輸入

http://localhost:8080/

就可以開啟 /path/to/project 資料夾內的內容

關閉 server

這時候直接在終端機按下 Ctrl + C 中斷 webpack-dev-server 即可

環境 - Mac OSX 10.10.2, npm 2.11.2, webpack-dev-server 1.10.0

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5