leafo / scssphp

SCSS compiler written in PHP
MIT License
1.34k stars 214 forks source link

[Feature] Versioned files #685

Closed raffaelecarelle closed 5 years ago

raffaelecarelle commented 5 years ago

Hi everyone,

I'd like to version the output css files (example: style.3a65d1.css).

Could the compiler implement this feature?

Thank you all.

Cerdic commented 5 years ago

Definitely not the job of the compiler which is returning the plain text css content, not a filename.

Could be in the Server class as an example, but however it's more the job of the caller to do this (being the Server class or you own application)

AdamPerkins commented 5 years ago

@raffaelecarelle

CSS (and js) files shouldn't be saved with a version-id on disk. It makes the file handling only complicated. One way is to call them like this: <link rel="stylesheet" href="/themes/default/css/cms-min.css?v=db261">

A better way (but much more difficult) is to create a hash and use this for versioning AND integrity: https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity

robocoder commented 5 years ago

Out of scope for the library.