serve.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. console.log('config.entry:', config.entry);
  14. browserSync({
  15. server: {
  16. baseDir: 'build',
  17. middleware: [
  18. webpackDevMiddleware(bundler, {
  19. // IMPORTANT: dev middleware can't access config, so we should
  20. // provide publicPath by ourselves
  21. publicPath: config.output.publicPath,
  22. // pretty colored output
  23. stats: config.stats,
  24. hot: true,
  25. historyApiFallback: true
  26. // for other settings see
  27. // http://webpack.github.io/docs/webpack-dev-middleware.html
  28. }),
  29. // bundler should be the same as above
  30. webpackHotMiddleware(bundler)
  31. ]
  32. },
  33. // no need to watch '*.js' here, webpack will take care of it for us,
  34. // including full page reloads if HMR won't work
  35. files: [
  36. 'build/**/*.css',
  37. 'build/**/*.html'
  38. ]
  39. });