Comments (3)
Fixed, following the example code for the server webpack config part I added:
output: {
path: resolve(__dirname, 'public'),
filename: 'server.js',
libraryTarget: 'commonjs2'
}
from webpack-hot-server-middleware.
Your server entry looks fine, could you share your webpack config and middleware calling code?
from webpack-hot-server-middleware.
webpack.config.js:
const webpack = require('webpack');
const { resolve } = require('path');
module.exports = [{
name: 'client',
target: 'web',
entry: [
'react-hot-loader/patch',
'webpack-hot-middleware/client',
'webpack/hot/only-dev-server',
'./src/index.js'
],
output: {
path: resolve(__dirname, 'public'),
filename: 'bundle.js',
publicPath: '/'
},
devtool: 'inline-source-map',
devServer: {
hot: true,
publicPath: '/',
contentBase: resolve(__dirname, 'public')
},
module: {
loaders: [
{
test: /\.json$/,
loader: 'json-loader',
include: /src/
},
{
test: /\.js$/,
loader: 'babel-loader',
include: /src/
}
]
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin(),
new webpack.NoEmitOnErrorsPlugin()
]
}, {
name: 'server',
target: 'node',
entry: './server.js',
module: {
loaders: [
{
test: /\.json$/,
loader: 'json-loader',
exclude: /node_modules/
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
}
]
}
}
];
index.js:
import config from './config';
import apiRouter from './src/api/index';
import path from 'path';
import express from 'express';
import webpackDevMiddleware from 'webpack-dev-middleware';
import webpackHotMiddleware from 'webpack-hot-middleware';
import webpackHotServerMiddleware from 'webpack-hot-server-middleware';
import webpackConfig from './webpack.config';
import webpack from 'webpack';
const bundler = webpack(webpackConfig);
const app = express();
app.use(webpackDevMiddleware(bundler, {
publicPath: '/',
stats: 'minimal'
}));
app.use(webpackHotMiddleware(bundler.compilers.find(compiler => compiler.name === 'client')));
app.use(webpackHotServerMiddleware(bundler));
app.use('/api', apiRouter);
app.use(express.static('public'));
app.listen(config.port, config.host, () => {
console.info('Express listening on port', config.port);
});
from webpack-hot-server-middleware.
Related Issues (20)
- Side effect from require server render from string
- listen EADDRINUSE: address already in use :::8080 HOT 2
- please remove `yarn` from dependencies HOT 4
- TypeError: serverRenderer is not a function
- Hangs when errors are thrown inside server bundle HOT 1
- filtering websocket webpack-hot-reloading calls from react-hot-server-middleware HOT 1
- serverRenderer is not a function HOT 10
- serverRenderer is not a function HOT 1
- My entry chunk is renamed to an async chunk HOT 2
- is it possible to call the default route from another route in express HOT 5
- serverRender is not a function
- use webpack-hot-server-middleware with typescript HOT 2
- Another "serverRenderer is not a function" question. HOT 4
- React Redux store not found in context HOT 4
- cannot find module 'react'
- Why is yarn in runtime dependencies? HOT 1
- Separating Routes? HOT 6
- Error is thrown when the example is run.
- Error when compiling when using Hapijs HOT 1
- bug flow type HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webpack-hot-server-middleware.