serve.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /**
  2. * React Static Boilerplate
  3. * https://github.com/koistya/react-static-boilerplate
  4. * Copyright (c) Konstantin Tarkus (@koistya) | MIT license
  5. */
  6. import browserSync from 'browser-sync';
  7. import webpack from 'webpack';
  8. import webpackDevMiddleware from 'webpack-dev-middleware';
  9. import webpackHotMiddleware from 'webpack-hot-middleware';
  10. global.watch = true;
  11. const config = require('./config')[0];
  12. const bundler = webpack(config);
  13. browserSync({
  14. server: {
  15. baseDir: 'build',
  16. middleware: [
  17. webpackDevMiddleware(bundler, {
  18. // IMPORTANT: dev middleware can't access config, so we should
  19. // provide publicPath by ourselves
  20. publicPath: config.output.publicPath,
  21. // pretty colored output
  22. stats: config.stats,
  23. hot: true,
  24. historyApiFallback: true
  25. // for other settings see
  26. // http://webpack.github.io/docs/webpack-dev-middleware.html
  27. }),
  28. // bundler should be the same as above
  29. webpackHotMiddleware(bundler)
  30. ]
  31. },
  32. // no need to watch '*.js' here, webpack will take care of it for us,
  33. // including full page reloads if HMR won't work
  34. files: [
  35. 'build/**/*.css',
  36. 'build/**/*.html'
  37. ]
  38. });