May 2018
Intermediate to advanced
470 pages
13h 54m
English
In order to keep the development flow simple, we will initialize Webpack to compile the client-side code when the server is run. In devBundle.js, we will set up a compile method that takes the Express app and configures it to use the Webpack middleware to compile, bundle, and serve code, as well as enable hot reloading in development mode.
mern-simplesetup/server/devBundle.js:
import webpack from 'webpack'import webpackMiddleware from 'webpack-dev-middleware'import webpackHotMiddleware from 'webpack-hot-middleware'import webpackConfig from './../webpack.config.client.js'const compile = (app) => { if(process.env.NODE_ENV == "development"){ const compiler = webpack(webpackConfig) const middleware = webpackMiddleware(compiler, ...Read now
Unlock full access