Skip to content

Sometimes it hits the cache when the files are not on disk  #264

@emirotin

Description

@emirotin

Hi

This tool is nice and convenient, thanks. But recently I started getting a very strange Shroedingbug.
Quite often if I clear the previously generated sprites and then run the build, it would report that the files were not changed, and skip writing them to disk. This ultimately leads to the build failure.
I wasn't able to reproduce it in debug mode, so it can be some kind of the race condition.

For now, I have commented these lines in my locally patched copy of the plugin:

diff --git a/node_modules/postcss-easysprites/lib/sprites.js b/node_modules/postcss-easysprites/lib/sprites.js
index c143a18..1ed7126 100644
--- a/node_modules/postcss-easysprites/lib/sprites.js
+++ b/node_modules/postcss-easysprites/lib/sprites.js
@@ -52,11 +52,11 @@ async function saveSpriteFile(spriteElement) {
   // Build the full path the sprite file should be saved to.
   sprite.path = path.resolve(opts.spritePath, `${sprite.groups}.png`);
 
-  // If the sprite is being pulled from the cache, don't save a new version.
-  if (sprite.isFromCache) {
-    log('Easysprites:', ansi.green(sprite.path), 'unchanged.');
-    return sprite;
-  }
+  // // If the sprite is being pulled from the cache, don't save a new version.
+  // if (sprite.isFromCache) {
+  //   log('Easysprites:', ansi.green(sprite.path), 'unchanged.');
+  //   return sprite;
+  // }
 
   // Save new version of the sprite image file.
   await writeFileAsync(sprite.path, Buffer.from(sprite.image, 'binary'));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions