Created
February 19, 2018 13:15
-
-
Save kimobrian/22de51fd7308ee38d8232142591cb872 to your computer and use it in GitHub Desktop.
Express webpack serve issue
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
var express = require('express'); | |
var app = express(); | |
var webpack = require('webpack'); | |
var path = require('path'); | |
var compiler = webpack(require('./webpack.config.js')); | |
app.use(require('webpack-dev-middleware')(compiler, { | |
noInfo: true, | |
publicPath: '/' | |
})); | |
app.use('*', function (req, res, next) { | |
var filename = path.join(compiler.outputPath,'index.html'); | |
compiler.outputFileSystem.readFile(filename, function(err, result){ | |
if (err) { | |
return next(err); | |
} | |
res.set('content-type','text/html'); | |
res.send(result); | |
res.end(); | |
}); | |
}); | |
app.listen(3000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment