welaika / wordless

All the power of Pug, Sass, Coffeescript and WebPack in your WordPress theme. Stop writing themes like it's 1998.
https://www.wptools.it/wordless
1.43k stars 107 forks source link

Asset cache create problems in css compilation #98

Closed endorama closed 12 years ago

endorama commented 12 years ago

With assets cache enabled if you include more than one css in the page only one css is returned.

Example of this behaviour:

In _head.haml I have:

<?php
= stylesheet_link_tag("bootstrap")
= stylesheet_link_tag("screen")

Both are compiled correctly in the tmp folder, but if I click on bootstrap.css link and on screen.css I get the same file content ( which is the content of the bootstrap.css file, as it comes before the other... )

I found a workaround: To prevent this behaviour you must DISABLE assets.cache_enabled:

<?php
Wordless::set_preference("assets.cache_enabled", false);
endorama commented 12 years ago

The caching system implemented in Wordless create a hash from the concatenation of all sass files found inside the theme/assets/stylesheet folder, so that if one of that files is changed ( regardless of what file it is ) the hash changes and the cache is rebuilt.

To overcome this problem the hash need to be unique for every root sass file, but this means that we must understand which partials are imported in the root sass file, creating the hash with only the content included in the root file.

STRML commented 12 years ago

Would it not be enough for the hash to be unique for each root sass file alone? It should be safe to assume that each root sass file is unique, even if they only contain @import statements. Changing any SASS file would start a recompile which is suboptimal but a lot less work and should fix this bug.

What I am proposing is that we maintain two hashes - a unique hash for each root SASS file, and a hash of all SASS files in the theme. The root hash is used to return the cached_file_path.

I'll work on a pull request.

STRML commented 12 years ago

We can close this issue.