-
-
Notifications
You must be signed in to change notification settings - Fork 201
can not reload css when scss changed in dev server hot #348
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
Comments
Yea, that's correct - we always extract to a CSS file, which kills HMR. We did this on purpose - because we wanted to consistently output CSS files (not have different behavior between prod & dev environments). I've always wanted to add HMR for extracted CSS files, but it's always been a "todo" in the core webpack libs. For example, HMR is listed as a "TODO" on the https://github.com/webpack-contrib/mini-css-extract-plugin that we're using in the next version. One option is to add a method to "opt in" to not extracting to CSS when in |
Hey Ryan, Is this anywhere documented? Where I have to set this option? |
Why does this package not work with Encore? |
@tech-nomad What @weaverryan meant is that a method could be added to Encore to allow people not to use the AFAIK you should be able to use
|
Thanks for the info @Lyrkan ! |
I do agree with the @tech-nomad's opinion, the "live reload" feature or HMR should be available. |
@tech-nomad and all, as a workaround / until it is an option. In my projects I add the following to the ...
const cfg = Encore.getWebpackConfig();
if (process.env.NODE_ENV === 'development') {
// allow HMR of scss/css changes
// https://github.com/symfony/webpack-encore/issues/348#issuecomment-408631993
const path = require('path');
cfg.module.rules = cfg.module.rules.map(rule => {
if (rule.use && rule.use[0] === path.resolve(__dirname, 'node_modules/mini-css-extract-plugin/dist/loader.js')) {
rule.use[0] = require.resolve("style-loader");
}
return rule;
});
}
module.exports = cfg; This changes both the css and scss/sass module rules to use This requires prepending the
And requires adding |
@AubreyHewes Thanks for the solution, just add, it also works for me without updating
|
…kan) This PR was merged into the master branch. Discussion ---------- Add Encore.disableCssExtraction() to the public API This PR adds an `Encore.disableCssExtraction()` method that allows to disable the `mini-css-extract-plugin` and use the `style-loader` instead. It can be used to solve various problems that, until now, required a really ugly workaround that relied on our internal implementation (for instance the following commit probably broke some builds that used previous versions of it: 6867443#diff-8beacd21a12ca072bafa4e8e3f1aae6b). Related issues: #3, #256, #348, #527 Commits ------- 347feed Add Encore.disableCssExtraction() to the public API
I think this issue can now be close since the commit #539 introduced the requested feature
Then, the command
Works as expected |
Maybe this can be added to the |
I'd prefer to merge #564 since it should then work natively with the Anyway, if we do add |
Yes, I was thinking about using |
in dev server environment sass file also be extract to a css file which imported in main.js.so , it can not been hoted in dev server. can use only
sass-loader
,style-loader
to solve it in dev server enviroment in encore,or let us to configure it self by add a methodisDevServer
to check if in dev-server?The text was updated successfully, but these errors were encountered: