J Maushagen J Maushagen - 5 months ago 50
Node.js Question

webpack-dev-middleware does not compile output into folder

I'm using webpack-dev-middleware in my server to compile javascript like this:

if (development){
// webpack options
// webpackMiddleware takes a Compiler object as first parameter
// which is returned by webpack(...) without callback.
entry: {
dashboard: path.join(__dirname, 'scripts/dashboard.jsx'),
tasks: path.join(__dirname, 'scripts/tasks.jsx')
output: {
path: __dirname + 'dist',
filename: '[name].bundle.js',
// no real path is required, just pass "/"
// but it will work with other paths too.
resolve: {
extensions: ['', '.js', '.jsx']
module: {
loaders: [
{ test: /\.jsx$/, loader: "jsx" }
stats: {
colors: true

Everything works fine in development, I can include the bundles in my views. But in production I cannot include them, because they are not build into 'dist'. This folder is always empty. What do I do wrong?
Does somebody has an idea?

Best Regards


webpack-dev-middleware doesn't output any file. If you want to output real files, you need to use the webpack command outside of express. You can put your webpack config into a seperate file, and refer to that with both your webpack command and require it in your express script to access it.