Skip to content

Instantly share code, notes, and snippets.

@reciosonny
Created June 3, 2018 02:46
Show Gist options
  • Save reciosonny/a1554291f88777dfcb76abb16e40cc2f to your computer and use it in GitHub Desktop.
Save reciosonny/a1554291f88777dfcb76abb16e40cc2f to your computer and use it in GitHub Desktop.
Boilerplate code for running webpack app inside nodejs (you need to install `webpack-dev-middleware` in your app as devDependencies). #webpack #nodejs
const express = require('express');
/**
* we need to make use of all 3 to make webpack work
*/
const webpackMiddleware = require('webpack-dev-middleware'); //this only serves to intercept the incoming requests and handle webpack
const webpack = require('webpack'); //this exists to compile all of our application assets
const webpackConfig = require('./webpack.config.js'); //this instructs on how to run webpack correctly with configurations
/**END */
const app = express();
app.use(webpackMiddleware(webpack(webpackConfig)));
app.listen(3050, () => console.log('listening...'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment