Closed levino closed 7 years ago
The issue was in my .babelrc. One needs to set the preset for ES2015 like this:
["es2015", {"modules": false}],
See also: https://webpack.js.org/guides/hmr-react/#babel-config
I could not do it in my .babelrc because I need the modules for the webpack.config.babel.js
as I want to use import there instead of require. So I had to put the babel config into the webpack config and tell webpack to ignore the rc file like this:
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
query: {
babelrc: false,
presets: [
['es2015', { modules: false }],
'stage-2',
'react'
],
plugins: [
'react-hot-loader/babel'
// Enables React code to work with HMR.
]
}
}
]
}
]
}
After that everything worked fine.
So I am using this with HMR. I got everything working fine when I firstly load the app. But when I change something in my css file, I get an update in the app but the styles are not replaced with the new information but the class just vanishes from the head section of the html. I have to F5 to reload the page and the styles are added in the head section again.
It looks to me as if on update the css is removed from the head but not added again. I understand that this issue might be unrelated to this specific package, but I thought it might be worth while starting to ask here.
webpack.config.babel.js
devDeps from package.json: