Make frontend development 10-12x faster (compile SCSS through sass-embedded)#9081
Conversation
|
@andreslucena Regarding what I told few moments ago, this is generating the import map also for production builds. But I think this is the case with the existing configuration too, e.g. if you look at MetaDecidim: So from my perspective, it's done! |
andreslucena
left a comment
There was a problem hiding this comment.
👍🏽
A quick local check, from 30146 ms to 3972 ms 😄
|
Great to hear that ! Do you think a backport to 0.26 is possible ? I wonder how do you do to initially compile in less than a minute ? I have a standard Decidim setup, with 2 light CSS and JS files and webpacker takes 6mn on our server (a VM by the way) :/ |
microstudi
left a comment
There was a problem hiding this comment.
This is a great improvement, very much needed.
When testing it, in a newly created development_app, i found that if I use the command bin/webpack-dev-server some warnings appear:

Compiled with problems:
WARNING
InjectManifest has been called multiple times, perhaps due to running webpack in --watch mode. The precache manifest generated after the first call may be inaccurate! Please see https://github.com/GoogleChrome/workbox/issues/1790 for more information.
WARNING
/decidim-packs/js/vendors-node_modules_decidim_decidim-bulletin_board_src_index_js.js is 2.21 MB, and won't be precached. Configure maximumFileSizeToCacheInBytes to change this limit.
WARNING
/decidim-packs/js/vendors-node_modules_graphiql_esm_index_js-node_modules_graphiql_graphiql_css.js is 2.42 MB, and won't be precached. Configure maximumFileSizeToCacheInBytes to change this limit.
@microstudi These warnings are unrelated to this change. The same warnings appear with the current configurations. They come from Webpack. The first warning appears under the watch mode and the link provides additional information about that. The two other warnings are what they are... There's probably some crypto libraries included in the bulletin board JS which makes it large. The GraphiQL warning could be because it compiles the CSS within the JS (at least judging by that error). |
|
Thanks, I see that these message appear in other branches. Mergin develop over this one prevents from appearing into the browser. |
* develop: Compile SCSS through sass-embedded (#9081) Prevent race condition between prevenTimeout and show modal (#9092) Bump elections dependencies to 0.23.0 (#9140) Reduce d3 bundle size (#9034) Improve wording when casting your vote (#9098) Do not send upcoming meeting notification for hidden or withdrawn meetings (#9134) Fix processes count in processes group title cell (#9087) Fix attachments when called from Cells (#9136) Clarify message to user when checking census (#9112)
🎩 What? Why?
At #8783 the SCSS compilation speed was discussed. During a bit of comparison I figured that when bypassing Webpack during the SCSS compilation, it was 5-6x faster. Furthermore, when using the
sass-embedded(instead ofsass) package which uses the "embedded" version of the compiler (i.e. Dart version instead of JS version), it made the compilation even 2x faster from that.So, in total this resulted to 10-12x faster SCSS compile times.
This got me thinking why couldn't we use
sass-embeddedalso in Webpack. I figured it's not possible through configuring thesass-loaderplugin due to some bugs, so I built our own loader to pass the SCSS files tosass-embeddedinstead.The initial load time after starting
webpack-dev-serverdrops from 1-3 minutes (mileage may vary) down to ~20s and further reloads form ~20s+ down to ~3s.This makes developing frontend a more enjoyable experience.
Note that this does not solve any other issues with Webpacker, the related discussion is still valid. This is just a patch for the current situation that we still have to live with for some time.
Also note that Webpack is still slower than running the
scsscompiler directly but this is large enough improvement to the current situation.📌 Related Issues
Testing
Run the
webpack-dev-serverand experience a bit of joy for the first time.📋 Checklist
docs/.