-
-
Save vejandla/6966cabf27bede745e160cf264f0edff to your computer and use it in GitHub Desktop.
Using import for webpack libs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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