Advertisement
Guest User

Untitled

a guest
Dec 16th, 2015
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. import path from 'path';
  2. import express from 'express';
  3. import webpack from 'webpack';
  4. import webpackDevMiddleware from 'webpack-dev-middleware';
  5. import webpackHotMiddleware from 'webpack-hot-middleware';
  6. import appConfig from '../tools/config';
  7.  
  8. const app = express();
  9. const port = 3000;
  10. const compiler = webpack(appConfig);
  11.  
  12. app.use(webpackDevMiddleware(compiler, { noInfo: true, lazy: false, publicPath: appConfig.output.publicPath }));
  13. app.use(webpackHotMiddleware(compiler));
  14. app.use(express.static(path.join(__dirname, 'public')));
  15. app.use(function(req, res) {
  16. res.sendFile(__dirname + '/public/index.html')
  17. });
  18.  
  19. const server = app.listen(port, function (err) {
  20.  
  21. if(err) {
  22. console.log('Error');
  23. } else {
  24. let port = server.address().port;
  25. let host = server.address().address;
  26. console.log('Listening at http://%s:%s', host, port);
  27. }
  28. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement