grunt-compass-multiple icon indicating copy to clipboard operation
grunt-compass-multiple copied to clipboard

Why rewrite css if there where no changes?

Open dmitrybelyakov opened this issue 12 years ago • 5 comments

Hi,

I'm evaluating your this task and while doing some testing against grunt-contrib-compass I found rather weird thing.

Say we have multiple css we want to compile like: fonts.css, bootstrap.css and main.css. Then if one of them gets updated then on next compile all three will be rewritten with new versions. I'm not sure whether they a recompiled or just rewritten from cache, but even though - doesn't it waste time on updating those that where not changed?

May be it's bug? What do you think?

dmitrybelyakov avatar Aug 04 '13 15:08 dmitrybelyakov

Hi,

Thank you for interesting to this task.

When compiling unchanged files, is there any "identical" message such like below? "stdout: identical css3/css/sample1.css "

and, if compiling changed files, "override" message shows like this. "stdout: overwrite css/top.css"

If the above description is not correct for you, it may be a bug.

yoheiMune avatar Aug 05 '13 10:08 yoheiMune

Hi,

There was change in one file others were identical, so the messages were as you stated, but anyway all of them were overwritten probably from cache (for identical) as it took almost no time.

dmitrybelyakov avatar Aug 05 '13 10:08 dmitrybelyakov

Hi,

Grunt-compass-multiple use Compass for comiling. And Compass use Sass for compiling.

Sass version may cause the problem. In my environment, grunt-compass-multiple work below.

[Sass 3.3.0.alpha.198] if the target sass is NOT changed from the before compiling, grunt-compass-multiple shows below message. "stdout: unchanged css/scss/top.scss"

and if the target sass is changed, it shows below. "stdout: overwrite css/top.css "

[Sass 3.2.7] if the target sass is NOT changed, it shows below. "stdout: identical css/scss/top.scss"

and if the target sass is changed, it shows below. "stdout: overwrite css/top.css "

Perhaps, if Sass version is less than 3.3, the unchanged file will be overwritten from cache (stated identical). Could you check your sass version, and could you give me your information?

Thanks for your kindness.

yoheiMune avatar Aug 07 '13 02:08 yoheiMune

Ok got myself a little time to roll back and try this once again. So here is the thing: I'm compiling a real-life project that has 5 final css files:

  • animate.css
  • bootstrap.css
  • locales.css
  • screens.css
  • main.css

Each of those lives in a dedicated directory with sass files and is set up as parallel task with compass-multiple. I'm watching for changes in those sass files and run compilation on any change.

Now say I change the main.scss source and compilation is run. As you correctly stated the messages are following:

Running "compassMultiple:server" (compassMultiple) task
pathes:  [ 'app/sass/animate-css.scss', 'app/sass/locales.scss' ]
stdout:  identical .tmp/css/locales.css (0.284s)
Compilation took 0.285s

stdout:  identical .tmp/css/animate-css.css (0.806s)
Compilation took 0.807s

stdout:  identical .tmp/css/screens.css (1.04s)
Compilation took 1.093s

stdout:  overwrite .tmp/css/main.css (1.931s)
Compilation took 1.932s

stdout:  identical .tmp/css/bootstrap.css (2.752s)
Compilation took 2.754s

execTime: 3001ms

So as I told you before, the messages are correct. Now if I look at my output css files I see all of them were updated (looking at file creation date) even those that were identical. I'm on Sass 3.2.10 and Compass 0.12.2.

I'm just going into this because regular grunt-contrib-compass does not do that. If the source is updated only it gets compiled. All the identical files are left as is.

I did some additional benchmarking and it turns out if we use grunt-compass-multiple over grunt-contrib-compass the former provides very little benefit in compilation time. I wonder if it its because of this issue of overwriting identical unchanged files.

Cheers!.

dmitrybelyakov avatar Aug 08 '13 07:08 dmitrybelyakov

I think you may be interested in exact numbers of benchmarking. So we are testing grunt-contrib-compass and grunt-compass-multiple on the same code base. For each one we measure compilation time when we have one huge scss/css file and when we split it in 5 separate files as in my previous message.

grunt-contrib-compass - one large file
recompile on single file change - 10.14s

grunt-contrib-compass - multiple files
recompile on single file change - 2.45s

grunt-compass-multiple - one large file
recompile on single file change - 10.50s

grunt-contrib-compass - multiple files
recompile on single file change - 3.01s

dmitrybelyakov avatar Aug 08 '13 07:08 dmitrybelyakov