1
const webpack = require('webpack');
2
const [webpackClientConfig, webpackServerConfig] = require('../webpack.config');
3
const nodemon = require('nodemon');
4
const path = require('path');
5
const webpackDevMiddleware = require('webpack-dev-middleware');
6
const webpackHotMiddleware = require('webpack-hot-middleware');
7
const express = require("express");
9
const hmrserver = express();
10
const clientCompiler = webpack(webpackClientConfig);
12
hmrserver.use(webpackDevMiddleware(clientCompiler, {
13
publicPath: webpackClientConfig.output.publicPath,
14
serverSideRender: true,
19
hmrserver.use(webpackHotMiddleware(clientCompiler, {
20
path: '/static/__webpack_hmr',
23
hmrserver.listen(3001, () => {
24
console.log('HMR server successfully started');
27
const compiler = webpack(webpackServerConfig);
29
compiler.run((err) => {
31
console.log('Compiler failed: ', err);
33
compiler.watch({}, (err) => {
35
console.log('Compiler failed: ', err);
37
console.log('Compilation was successfully');
41
script: path.resolve(__dirname, '../dist/server/server.js'),
43
path.resolve(__dirname, '..dist/server'),
44
path.resolve(__dirname, '..dist/client'),