Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. // webpack.config.js
  2. module.exports = {
  3. ...
  4. target: 'node'
  5. ...
  6. }
  7.  
  8. // webpack.config.js
  9. module.exports = {
  10. ...
  11. plugins: [new webpack.HotModuleReplacementPlugin()]
  12. ...
  13. };
  14.  
  15. // webpack.config.js
  16. module.exports = {
  17. ...
  18. entry: [
  19. 'webpack/hot/poll?1000', // This differs from client side HMR
  20. 'app.js'
  21. ]
  22. ...
  23. };
  24.  
  25. // app.js
  26. let config = require('./config');
  27. setInterval(() => {
  28. console.log(config.FOO_BAR);
  29. }, 2000);
  30.  
  31. // NOTE: This would need to be done everywhere you use './config' so you might want to create a loader to generate it.
  32. if (module.hot) {
  33. module.hot.accept('./config', () => {
  34. let config = require('./config');
  35. });
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement