You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

пре 3 година
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #Browsersync - Webpack + Monkey Hot Loader
  2. ## Installation/Usage:
  3. To try this example, follow these 4 simple steps.
  4. **Step 1**: Clone this entire repo
  5. ```bash
  6. $ git clone https://github.com/Browsersync/recipes.git bs-recipes
  7. ```
  8. **Step 2**: Move into the directory containing this example
  9. ```bash
  10. $ cd bs-recipes/recipes/webpack.monkey-hot-loader
  11. ```
  12. **Step 3**: Install dependencies
  13. ```bash
  14. $ npm install
  15. ```
  16. **Step 4**: Run the example
  17. ```bash
  18. $ npm start
  19. ```
  20. ### Additional Info:
  21. To see `monkey-hot-loader` in action, edit top-level functions (`inc`, `dec`)
  22. inside `main.js` file
  23. ### Preview of `app.js`:
  24. ```js
  25. /**
  26. * Require Browsersync along with webpack and middleware for it
  27. */
  28. var browserSync = require('browser-sync');
  29. var webpack = require('webpack');
  30. var webpackDevMiddleware = require('webpack-dev-middleware');
  31. var webpackHotMiddleware = require('webpack-hot-middleware');
  32. /**
  33. * Require ./webpack.config.js and make a bundler from it
  34. */
  35. var webpackConfig = require('./webpack.config');
  36. var bundler = webpack(webpackConfig);
  37. /**
  38. * Run Browsersync and use middleware for Hot Module Replacement
  39. */
  40. browserSync({
  41. server: {
  42. baseDir: 'app',
  43. middleware: [
  44. webpackDevMiddleware(bundler, {
  45. // IMPORTANT: dev middleware can't access config, so we should
  46. // provide publicPath by ourselves
  47. publicPath: webpackConfig.output.publicPath,
  48. // pretty colored output
  49. stats: { colors: true }
  50. // for other settings see
  51. // http://webpack.github.io/docs/webpack-dev-middleware.html
  52. }),
  53. // bundler should be the same as above
  54. webpackHotMiddleware(bundler)
  55. ]
  56. },
  57. // no need to watch '*.js' here, webpack will take care of it for us,
  58. // including full page reloads if HMR won't work
  59. files: [
  60. 'app/css/*.css',
  61. 'app/*.html'
  62. ]
  63. });
  64. ```