windicss-webpack-plugin icon indicating copy to clipboard operation
windicss-webpack-plugin copied to clipboard

HMR for NextJS failed on windi.config.js change

Open donrsh opened this issue 3 years ago • 2 comments

Describe the bug As title. It seems windi.config.js change doesn't cause HMR on a next.js project.

To Reproduce Steps to reproduce the behavior:

  1. Clone repository: https://github.com/donrsh/issue-NextJS-HMR-on-windi-config-change
  2. Run yarn dev
  3. Visit http://localhost:3000
  4. Modify extend color in windi.config.js (e.g. red: "#f00" -> red: "#0f0")

Expected behavior Observe that the title that consumes text-red (pages/index.js - line15) class didn't change color. Even reload doesn't trigger the update. One needs to rerun the dev server for the change to apply.

Screenshots The color of highlighted texts should change. image

Additional context I work on Windows.

donrsh avatar Aug 30 '21 08:08 donrsh

Hey @donrsh

Thanks for the issue and reproduction link!

I took a quick look and unfortunately couldn't replicate the issue. Which means it's either one of two things:

  • Something weird going on with your caching, try deleting the node_modules/.cache folder
  • A windows specific issue on watching files

If it's not the first issue then it's a bit tricky for me to debug since I don't have windows. What might help is to run it in debug mode

    "dev": "set DEBUG=windicss-webpack* && next dev",

if set doesn't work, try cross-env

Can you see if you have a line like this

 windicss-webpack-plugin:plugin config dependency at /home/harlan/packages/webpack-windicss-plugin/issue-NextJS-HMR-on-windi-config-change/windi.config.js +60ms

Also can you paste the contents of the debug once you modify the file, if any

harlan-zw avatar Sep 01 '21 02:09 harlan-zw

Hi, @harlan-zw, thanks for the help.

By following the instruction, here's the results

  1. There is a line saying the windi.config.js is used: 擷取1

  2. No output to terminal after windi.config.js change. While modifying the page files DOES show some stuff: image

donrsh avatar Sep 02 '21 01:09 donrsh