Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to postcss.config.js do not take effect immediately after dev server restart #39410

Open
1 task done
ozzy1136 opened this issue Aug 9, 2022 · 2 comments
Open
1 task done
Labels
bug Issue was opened via the bug report template. Webpack Related to Webpack with Next.js.

Comments

@ozzy1136
Copy link

ozzy1136 commented Aug 9, 2022

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
Platform: win32
Arch: x64
Version: Windows 10 Home
Binaries:
Node: 16.16.0
npm: N/A
Yarn: N/A
pnpm: N/A
Relevant packages:
next: 12.2.5-canary.0
eslint-config-next: N/A
react: 18.2.0
react-dom: 18.2.0

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

next dev

Describe the Bug

On initial next dev, the source CSS files are processed as expected with the postcss.config.js configuration. This is evident by looking at the computed styles in devtools.
After making and saving changes to postcss.config.js and restarting the dev server, the computed styles do not reflect the changes made to the config file.
After saving a CSS file in a text editor, without even making changes to the file, and Next.js finishes compiling, usually the computed styles reflect the changes made to postcss.config.js (i.e. the source CSS file is processed as expected with the updated config file). Additionally, only that CSS file is processed with the updated postcss.config.js configuration; any other CSS file would have to be saved to update the computed styles.

Expected Behavior

After making changes to postcss.config.js and restarting the dev server, the output CSS should be processed with the updated PostCSS config file.

Link to reproduction

https://github.com/ozzy1136/next.js-postcss-config-test

To Reproduce

  1. Run git clone https://github.com/ozzy1136/next.js-postcss-config-test.git
  2. Run cd next.js-postcss-config-test
  3. Run npm install
  4. Run npm run dev
  5. Open web browser and inspect styles of <div> with class testDiv
  6. Close the running dev server with ^C
  7. Open postcss.config.js and change the value of "display-two-values" from true to false
  8. Save postcss.config.js
  9. Run npm run dev
  10. After compiling and page reload, save pages/test.module.css in text editor to process with updated PostCSS config file
@ozzy1136 ozzy1136 added the bug Issue was opened via the bug report template. label Aug 9, 2022
@balazsorban44 balazsorban44 added the Webpack Related to Webpack with Next.js. label Aug 9, 2022
@w55100
Copy link

w55100 commented Sep 30, 2022

We encountered same issue. run start can read the real-time config file, whereas run dev keeps old params in postcss.config.js.
We tried to yarn remove next-server and reinstall it with yarn add next-server, then latest config become effective.
It seems that next-server keeps config cache itself.

@tangye1234
Copy link
Contributor

You can remove .next/cache manually to make this change working immediately

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. Webpack Related to Webpack with Next.js.
Projects
None yet
Development

No branches or pull requests

4 participants