Created
June 3, 2018 02:46
-
-
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
This file contains 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
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