Skip to content

Instantly share code, notes, and snippets.

@vejandla
Forked from coryhouse/srcServer.js
Created September 20, 2017 02:41
Show Gist options
  • Save vejandla/6966cabf27bede745e160cf264f0edff to your computer and use it in GitHub Desktop.
Save vejandla/6966cabf27bede745e160cf264f0edff to your computer and use it in GitHub Desktop.
Using import for webpack libs
import express from 'express';
import webpack from 'webpack';
import path from 'path';
import config from '../webpack.config.dev';
import open from 'open';
import webpackDevMiddleware from 'webpack-dev-middleware';
import webpackHotMiddleware from 'webpack-hot-middleware';
/* eslint-disable no-console */
const port = 3000;
const app = express();
const compiler = webpack(config);
app.use(webpackDevMiddleware(compiler, {
noInfo: true,
publicPath: config.output.publicPath
}));
app.use(webpackHotMiddleware(compiler));
app.get('*', function(req, res) {
res.sendFile(path.join( __dirname, '../src/index.html'));
});
app.listen(port, function(err) {
if (err) {
console.log(err);
} else {
open(`http://localhost:${port}`);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment