Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

3 anni fa
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #Browsersync - Webpack + React 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.react-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 `react-hot-loader` in action, edit `js/HelloWorld.jsx`
  22. ### Preview of `app.js`:
  23. ```js
  24. /**
  25. * Require Browsersync along with webpack and middleware for it
  26. */
  27. var browserSync = require('browser-sync');
  28. var webpack = require('webpack');
  29. var webpackDevMiddleware = require('webpack-dev-middleware');
  30. var webpackHotMiddleware = require('webpack-hot-middleware');
  31. /**
  32. * Require ./webpack.config.js and make a bundler from it
  33. */
  34. var webpackConfig = require('./webpack.config');
  35. var bundler = webpack(webpackConfig);
  36. /**
  37. * Run Browsersync and use middleware for Hot Module Replacement
  38. */
  39. browserSync({
  40. server: {
  41. baseDir: 'app',
  42. middleware: [
  43. webpackDevMiddleware(bundler, {
  44. // IMPORTANT: dev middleware can't access config, so we should
  45. // provide publicPath by ourselves
  46. publicPath: webpackConfig.output.publicPath,
  47. // pretty colored output
  48. stats: { colors: true }
  49. // for other settings see
  50. // http://webpack.github.io/docs/webpack-dev-middleware.html
  51. }),
  52. // bundler should be the same as above
  53. webpackHotMiddleware(bundler)
  54. ]
  55. },
  56. // no need to watch '*.js' here, webpack will take care of it for us,
  57. // including full page reloads if HMR won't work
  58. files: [
  59. 'app/css/*.css',
  60. 'app/*.html'
  61. ]
  62. });
  63. ```