Closed kthalmann closed 6 years ago
Hi @kthalmann, thanks for your issue!
You're right, the watch mode is not working correctly. I've just checked this (without webpack-encore) and confirm it.
I'll try to fix this on the weekend.
Should be fixed now in the branch fix/watchmode
@kthalmann would you please test if it works in your setup as well?
npm install --save-dev git+https://github.com/SassNinja/media-query-plugin.git#fix/watchmode
Unfortunately I still get the same results. The media queries are getting appended to the files after every rerun. No errors during the build.
Would you create a full example setup with encore? (e.g. via gist or codesandbox)
I'm not able to create a working setup with mini-css-extract-plugin (even without my plugin). So far it seems easier to me to work directly with webpack...
Here's a draft what I tried https://codesandbox.io/s/24rlpy7y7n
Sorry for the delay. Actually the problem doesn't seem to be Encore. I did a clean setup without Encore and the problem persists. Here is my setup: https://gist.github.com/kthalmann/2c1cae9ed6939a45bea6f30f02967d59
to use encore with webpack 4 you have to use the master branch at the moment "@symfony/webpack-encore": "git://github.com/symfony/webpack-encore.git#master"
hope that helps
alright, I'm now able to reproduce it!
If you use only one query in the options (what I did) it doesn't occur. But any further query has got the same problem again.
I'll try to fix this
I've worked over the code to have a safe way to remove the CSS from the previous compilation. My tests were all successful – no more duplicate CSS in the extracted files.
Please check and let me know if it works for your setup as well!
Yes, good job! Expected results in my setups with and without encore.
Glad to hear :)
I've merged the fix now so it's going to be in the next minor release (1.1.0)
First, props for this plugin! It's time we use separate files for media queries to prevent unnecessary render blocking.
I'm using the symfony/webpack-encore bundle for an easy webpack configuration. When I use
yarn run encore dev --watch
to automatically recompile the assets, after the first changes and recompiling I can see that the media queries are extracted multiple times. If I quit the watch task and run it again the media queries seem extracted correctly again.