Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import path from 'path';
- import express from 'express';
- import webpack from 'webpack';
- import webpackDevMiddleware from 'webpack-dev-middleware';
- import webpackHotMiddleware from 'webpack-hot-middleware';
- import appConfig from '../tools/config';
- const app = express();
- const port = 3000;
- const compiler = webpack(appConfig);
- app.use(webpackDevMiddleware(compiler, { noInfo: true, lazy: false, publicPath: appConfig.output.publicPath }));
- app.use(webpackHotMiddleware(compiler));
- app.use(express.static(path.join(__dirname, 'public')));
- app.use(function(req, res) {
- res.sendFile(__dirname + '/public/index.html')
- });
- const server = app.listen(port, function (err) {
- if(err) {
- console.log('Error');
- } else {
- let port = server.address().port;
- let host = server.address().address;
- console.log('Listening at http://%s:%s', host, port);
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement