app.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /**
  2. * Require Browsersync along with webpack and middleware for it
  3. */
  4. var browserSync = require('browser-sync');
  5. var webpack = require('webpack');
  6. var webpackDevMiddleware = require('webpack-dev-middleware');
  7. var webpackHotMiddleware = require('webpack-hot-middleware');
  8. /**
  9. * Require ./webpack.config.js and make a bundler from it
  10. */
  11. var webpackConfig = require('./webpack.config');
  12. var bundler = webpack(webpackConfig);
  13. /**
  14. * Run Browsersync and use middleware for Hot Module Replacement
  15. */
  16. browserSync({
  17. server: {
  18. baseDir: 'app',
  19. middleware: [
  20. webpackDevMiddleware(bundler, {
  21. // IMPORTANT: dev middleware can't access config, so we should
  22. // provide publicPath by ourselves
  23. publicPath: webpackConfig.output.publicPath,
  24. // pretty colored output
  25. stats: { colors: 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. 'app/css/*.css',
  37. 'app/*.html'
  38. ]
  39. });