2createStudio / postcss-sprites

Generate sprites from stylesheets.
MIT License
413 stars 50 forks source link

Option to disable image sprite overwrite #75

Closed niksy closed 7 years ago

niksy commented 7 years ago

I’m creating sprite based on hashed image buffer and if I have same output filename (two input CSS files have same final sprite) it gets written twice which creates problems if you want that sprite to be inlined since you would get into racing conditions when writing file to disk and reading it’s contents for inlining.

One option is to create final filename with groups and that works as it should, but maybe there could be option to skip writing same file to the disk if it already exists? Adding check for existence on https://github.com/2createStudio/postcss-sprites/blob/master/src/core.js#L350 could work.

What do you think? Does this make sense?

vvasilev- commented 7 years ago

I think that introducing such option will lead to unpredictable behavior of the plugin. You should use the groups to avoid conflicts with the name of files. :)

niksy commented 7 years ago

Just wanted to mention that this kind of thing also happens with postcss-copy plugin and there are some possible solutions using standard fs module: https://github.com/geut/postcss-copy/issues/50#issuecomment-270155684