Skip to content

Support cache#29

Open
baurine wants to merge 6 commits intomartonlederer:mainfrom
baurine:support-cache
Open

Support cache#29
baurine wants to merge 6 commits intomartonlederer:mainfrom
baurine:support-cache

Conversation

@baurine
Copy link

@baurine baurine commented Dec 6, 2021

What did

  • Support cache the .css/.less/.scss files compilation result (not support .styl yet, need help), to reduce the rebuild time in dev mode

Background

I use this plugin to compile the less and less module CSS files with esbuild for my a little large project. It works fine in the production mode, but in the dev mode, when we modify a CSS file, it cost more than 4s to make a rebuild, even we enable the incremental: true option. It doesn't satisfy us.

After investigating, we found the pure js code only cost hundreds of milliseconds to rebuild, most of the rebuild time is cost by compiling CSS.

According to the official advice, we can add the cache strategy for the plugin. So I try it, and it works amazing, the rebuild time is reduced from more than 4s to 600~700ms.

Result

In dev mode, enable incremental rebuild.

When enableCache: false, after changing a line of CSS code:

Build started
Build ended: 4660ms
Mapping /dashboard to "http://127.0.0.1:8888"
Serving "build" at http://127.0.0.1:8888
Ready for changes

Build started
...
CSS change detected build/diagnoseReport.css
CSS change detected build/dashboardApp.css
Change detected build/diagnoseReport.css.map
CSS change detected build/UserProfile-VBHKZLS6.css
Change detected build/UserProfile-VBHKZLS6.css.map
Change detected build/chunk-7CNVMG4T.js.map
Build ended: 4018ms

When enableCache: true, after changing a line of CSS code:

Build started
Build ended: 4564ms
Mapping /dashboard to "http://127.0.0.1:8888"
Serving "build" at http://127.0.0.1:8888
Ready for changes

Build started
...
Change detected build/chunk-ADLMHXCA.js
Change detected build/chunk-ADLMHXCA.js.map
Change detected build/chunk-DKAPZFJ6.js
Change detected build/chunk-DKAPZFJ6.js.map
Build ended: 699ms

@baurine baurine marked this pull request as draft December 6, 2021 09:33
@baurine
Copy link
Author

baurine commented Dec 10, 2021

If this PR is merged before PR #30 , then PR#30 can be closed because this PR includes the PR#30 changes to resolve the PR conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant