12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- /**
- * React Static Boilerplate
- * https://github.com/koistya/react-static-boilerplate
- * Copyright (c) Konstantin Tarkus (@koistya) | MIT license
- */
- import browserSync from 'browser-sync';
- import webpack from 'webpack';
- import webpackDevMiddleware from 'webpack-dev-middleware';
- import webpackHotMiddleware from 'webpack-hot-middleware';
- global.watch = true;
- const config = require('./config')[0];
- const bundler = webpack(config);
- export default async () => {
- await require('./build')();
- browserSync({
- server: {
- baseDir: 'build',
- middleware: [
- webpackDevMiddleware(bundler, {
- // IMPORTANT: dev middleware can't access config, so we should
- // provide publicPath by ourselves
- publicPath: config.output.publicPath,
- // pretty colored output
- stats: config.stats,
- hot: true,
- historyApiFallback: true
- // for other settings see
- // http://webpack.github.io/docs/webpack-dev-middleware.html
- }),
- // bundler should be the same as above
- webpackHotMiddleware(bundler)
- ]
- },
- // no need to watch '*.js' here, webpack will take care of it for us,
- // including full page reloads if HMR won't work
- files: [
- 'build/**/*.css',
- 'build/**/*.html'
- ]
- });
- };
|