implementation of HMR examples in ssr
See original GitHub issue💬 Questions and Help
Loadable Components project is young, but please before asking your question:
- Read carefully the README of the project
- Search if your answer has already been answered in old issues
After you can submit your question and we will be happy to help you!
First of all, sorry for bad English. I try to implementation hmr in this example of ssr projects. However, It says
I think ‘<’ is part of <!doctype html> because this hot-update.json file does not exists. I don’t know why this is not working.
I searched every issues on this repo about hmr, it does not help. Can you update your example of ssr with hmr??
Edited, I think this codes need to find out where my bug is. Below is webpack, basically almost same with example of ssr codes in this repo.
import path from 'path'
import webpack from 'webpack'
import nodeExternals from 'webpack-node-externals'
import LoadablePlugin from '@loadable/webpack-plugin'
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
const DIST_PATH = path.resolve(__dirname, 'public/dist')
const production = process.env.NODE_ENV === 'production'
const development =
!process.env.NODE_ENV || process.env.NODE_ENV === 'development'
const getConfig = target => ({
name: target,
mode: development ? 'development' : 'production',
target,
entry: target === 'web' ? ['webpack-hot-middleware/client', `./src/client/main-${target}.js`] : [`./src/client/main-${target}.js`],
module: {
rules: [
{
test: /\.js?$/,
exclude: /node_modules/,
use: [
{
loader: 'react-hot-loader/webpack',
},
{
loader: 'babel-loader',
options: {
caller: { target },
},
},
]
},
{
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
},
'css-loader',
],
},
],
},
externals:
target === 'node' ? ['@loadable/component', nodeExternals()] : undefined,
output: {
path: path.join(DIST_PATH, target),
filename: production ? '[name]-bundle-[chunkhash:8].js' : '[name].js',
publicPath: `/dist/${target}/`,
libraryTarget: target === 'node' ? 'commonjs2' : undefined,
},
plugins: target === 'web' ? [new webpack.HotModuleReplacementPlugin(), new LoadablePlugin(), new MiniCssExtractPlugin()] : [new LoadablePlugin(), new MiniCssExtractPlugin()],
})
export default [getConfig('web'), getConfig('node')]
server main.js
if (process.env.NODE_ENV !== 'production') {
/* eslint-disable global-require, import/no-extraneous-dependencies */
const { default: webpackConfig } = require('../../webpack.config.babel')
const webpackDevMiddleware = require('webpack-dev-middleware')
const webpackHotMiddleware = require('webpack-hot-middleware')
const webpack = require('webpack')
/* eslint-enable global-require, import/no-extraneous-dependencies */
const compiler = webpack(webpackConfig)
app.use(webpackHotMiddleware(compiler))
app.use(webpackDevMiddleware(compiler, {
noInfo: true,
publicPath: '/dist/web',
writeToDisk: true,
// writeToDisk(filePath) {
// return /dist\/node\//.test(filePath) || /loadable-stats/.test(filePath)
// },
}))
}
and some react-hot-loader codes in client, but this is not important.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:12
Top Results From Across the Web
implementation of HMR examples in ssr · Issue #323 - GitHub
I try to implementation hmr in this example of ssr projects. However, It says. image. I think '<' is part of <!doctype html>...
Read more >Implementation of HMR(Hot Module Replacement) to Angular ...
In this article, I would like to show you how to implement HMR-Hot Module Replecament to your Angular project.
Read more >React HMR with SSR - Stack Overflow
I think the solve of this trouble is mechanism called HMR (hot module replacement), but setting up this is hard for me. What...
Read more >Hot Module Replacement in Redux - Toptal
This is a minimal example of hot module replacement (or HMR) in a Redux application. The working demo code is hosted on GitHub....
Read more >Hot Module Replacement - webpack
There are many other loaders and examples out in the community to make HMR interact smoothly with a variety of frameworks and libraries......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@xkguq007 How to fix it ?
I’ll leave my entire webpack codes. It works.
webpack.client.config.js
webpack.server.config.js
webpack.config.js