From 164f05bebbe507d855720ba39be9653c0be7bc7a Mon Sep 17 00:00:00 2001 From: phra Date: Thu, 15 Sep 2016 00:58:18 +0200 Subject: [PATCH] add browsersync support, fixes #180 --- package.json | 4 +++- webpack.config.js | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 203c5f2a..7042fb44 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "clean-start": "npm run clean-install && npm start", "watch": "webpack --watch --progress --profile", "build": "rimraf dist && webpack --progress --profile --bail", - "server": "webpack-dashboard -- webpack-dev-server --inline --port 8080", + "server": "webpack-dashboard -- webpack-dev-server --inline --host 0.0.0.0 --port 8082", "webdriver-update": "webdriver-manager update", "webdriver-start": "webdriver-manager start", "lint": "tslint --force \"src/**/*.ts\"", @@ -47,6 +47,8 @@ "@types/selenium-webdriver": "^2.44.26", "angular2-template-loader": "^0.4.0", "autoprefixer": "^6.3.2", + "browser-sync": "^2.16.0", + "browser-sync-webpack-plugin": "^1.1.2", "codelyzer": "0.0.26", "copy-webpack-plugin": "^3.0.0", "css-loader": "^0.23.0", diff --git a/webpack.config.js b/webpack.config.js index ae3124e4..4719a178 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -9,6 +9,7 @@ var HtmlWebpackPlugin = require('html-webpack-plugin'); var ExtractTextPlugin = require('extract-text-webpack-plugin'); var CopyWebpackPlugin = require('copy-webpack-plugin'); var DashboardPlugin = require('webpack-dashboard/plugin'); +var BrowserSyncPlugin = require('browser-sync-webpack-plugin'); /** * Env @@ -167,6 +168,27 @@ module.exports = function makeWebpackConfig() { if (!isTest && !isProd) { config.plugins.push(new DashboardPlugin()); + config.plugins.push(new BrowserSyncPlugin( + // BrowserSync options + { + // browse to http://localhost:3000/ during development + host: '0.0.0.0', + port: 8080, + ui: { + port: 8081 + }, + // proxy the Webpack Dev Server endpoint + // (which should be serving on http://localhost:3100/) + // through BrowserSync + proxy: 'http://0.0.0.0:8082/' + }, + // plugin options + { + // prevent BrowserSync from reloading the page + // and let Webpack Dev Server take care of this + reload: false + } + )); } if (!isTest) {