Guest User

Untitled

a guest
Dec 11th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. const express = require('express');
  2. const webpack = require('webpack');
  3. const path = require('path');
  4. const webpackConfig = require('../config/webpack.config');
  5.  
  6. const config = {
  7. PORT: 8080
  8. };
  9.  
  10. const compiler = webpack(webpackConfig);
  11.  
  12. const server = express();
  13.  
  14. server.use(
  15. require('webpack-dev-middleware')(compiler, {
  16. noInfo: true,
  17. publicPath: webpackConfig.output.publicPath
  18. })
  19. );
  20. server.use(require('webpack-hot-middleware')(compiler));
  21.  
  22. server.get('*', function(req, res) {
  23. res.sendFile(path.join(__dirname, '/../index.html'));
  24. });
  25.  
  26. // Prepare to receive requests.
  27. server.listen(config.PORT, err => {
  28. if (err) throw err;
  29. });
Add Comment
Please, Sign In to add comment