Skip to content

Instantly share code, notes, and snippets.

@d7my11
Created February 6, 2018 12:05
Show Gist options
  • Save d7my11/dbd7981508a4b377e1f4be24f8c8de00 to your computer and use it in GitHub Desktop.
Save d7my11/dbd7981508a4b377e1f4be24f8c8de00 to your computer and use it in GitHub Desktop.
import open from 'open';
import express from 'express';
import webpack from 'webpack';
import config from './webpack.config.dev';
import conf from './conf';
/* eslint-disable no-console */
const port = 3000;
const app = express();
const compiler = webpack(config);
app.use(express.static(__dirname + '/'));
app.use(require('webpack-dev-middleware')(compiler, {
noInfo: true,
publicPath: config.output.publicPath
}));
app.use(require('webpack-hot-middleware')(compiler));
app.get('*', (req, res) => {
console.log(conf.paths.entry.html);
res.sendFile(conf.paths.entry.html);
});
app.listen(port, 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