app.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /**
  2. * Require Browsersync along with webpack and middleware for it
  3. */
  4. var browserSync = require('browser-sync').create();
  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.dev');
  12. var bundler = webpack(webpackConfig);
  13. /**
  14. *
  15. */
  16. browserSync.init({
  17. server: 'app',
  18. middleware: [
  19. webpackDevMiddleware(bundler, {
  20. // IMPORTANT: dev middleware can't access config, so we should
  21. // provide publicPath by ourselves
  22. publicPath: webpackConfig.output.publicPath,
  23. // pretty colored output
  24. stats: {colors: 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. // no need to watch '*.js' here, webpack will take care of it for us,
  32. // including full page reloads if HMR won't work
  33. files: [
  34. 'app/css/*.css',
  35. 'app/*.html'
  36. ]
  37. });