6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

webpack(4)でBrowserSyncをもっと簡単に使う

Last updated at Posted at 2020-03-12

概要

  • browser-sync-webpack-pluginを使う(更新がちょっと古い気がする)
  • dev-serverはPHPビルトインサーバーを使う(webpack-dev-serverの設定も面倒で)

コマンド&コード

$ npm install --save-dev browser-sync-webpack-plugin browser-sync
package.json
~~省略

  "scripts": {
    "watch": "php -S 0.0.0.0:8000 & webpack --watch --config webpack.config.js",

~~省略
webpack.config.js
~~省略
  plugins: [
    new BrowserSyncPlugin({
      host: "localhost",
      port: 3000,
      proxy: "http://localhost:8000"
    })
  ]
~~省略

あとは

$ npm run watch

を叩けばBrowserSyncで自動ブラウザリロード環境ができる。

参考

browser-sync-webpack-plugin

6
6
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
6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?