Closed thiphariel closed 5 years ago
Which webpack version are you using? Might be the webpack version as v4 did some breaking changes to plugins as far as I know.
I'm using webpack v4 yup :
"webpack": "^4.15.1",
"webpack-cli": "^3.0.8",
"webpack-dev-server": "^3.1.4"
Should I use webpack@3.x ?
As a user, I’ve been testing with webpack 3.12.0 because that’s what create-react-app
gave me. However this project itself is using webpack 4 and I did initially write a webpack 4 version of this plugin but that didn’t work with webpack 3. I had hoped it would be compatible. 🙁
Maybe I need to bundle two separate webpack plugins here. I’ll look into it.
I'll try to downgrade to webpack 3, I'll have some change to do to my config and maybe downgrade some others plugins to. I'll come back to you soon :)
Ok, so I downgrade to webpack 3, webpack-dev-server 2, and it's ok, my dev server running up again. Buuuuuuut ...
Styles don't reload when editing my React component :(
Here is my component
import React, { Component } from "react"
import { hot } from "react-hot-loader"
import withStyles from "react-jss"
const styles = {
container: {
background: "red"
}
}
class App extends Component {
... bla bla bla ...
render() {
const { classes } = this.props
const { loading, text } = this.state
return (
<div className={classes.container}>
Hello world !
{loading ? (
<div> Fetching data ...</div>
) : (
<div>Text from API : {text}</div>
)}
</div>
)
}
}
export default hot(module)(withStyles(styles)(App))
Edit : As I said, it's working great with the branch fix/hmr
on react-jss
repo
I just finished a quick upgrade of my CRA-based app to webpack 4.15.1 (and webpack-dev-server 3.1.4) and actually it worked ok, I didn’t get the BREAKING CHANGE error and hot reloading does work.
I noticed you don’t have plugins: ['react-hot-loader/babel']
in your webpack config - I tried deleting it from mine and I get errors in the browser console during hmr.
Is there any way you could provide a cut-down sample that I can test?
I have it in my .babelrc
{
"presets": ["env", "react"],
"plugins": ["transform-class-properties", "react-hot-loader/babel"]
}
EDIT : I'll push the sample code to github, give me a minute, I have to rollback to the webpack 4. I'll give you that in about 30min sorry !
Here you go @felthy : https://github.com/thiphariel/react-jss-hmr-bug
Sorry for the delay.
Just npm i
and npm run dev
to get the error
Thanks @thiphariel! I think the problem is that you added the plugin to the main webpack plugins section, not as a resolver plugin. I’ll add an extra note about that in the README. I sorry I didn’t notice the problem when you posted your config earlier!
To fix, add a new section to the config:
resolve: {
plugins: [
new ReactJssHmrPlugin(),
],
},
and remove the plugin from the other place.
Nice catch ! It works great, thanks :)
Closed
Okay so this works and we could move that to the cssinjs
org?
I confirm that is working great with webpack 4, webpack-dev-server 3, react-jss 8.6.1
Hi !
I tried this plugin as I said on the
react-jss
repo. I first tried yourfix/hmr
branch on the main repo and it works flawlessly.I revert to the master branch and added this plugin to my webpack config, but it seems not working with
webpack-dev-server
Here is the stack :Here is my
webpack.config.js
:and my npm scripts
Any tips ?