You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey there, I find staticify real handy in a prebuild and deploy scenario, there's just a few issues with replacePaths that mean it doesn't currently work completely for my use case:
Consider CSS that looks like this, if Object.keys returns the woff path before the woff2 path, the hash for the .woff path will actually end up on the .woff2, meaning a broken link in production.
Should be easily fixed with a length sort of Object.keys(versions), so longer strings get handled before shorter strings.
String.replace only replaces the first instance when used with strings.
Usually not an issue in my builds, but if a file is referenced more than once replacePaths won't currently pick it up. Better to turn it into a new RegExp(url, "g"), the global flag will ensure it gets everything.
I think this code should fit the bill but I didn't want to create a pull request and be presumptive, let me know if you want me to create one.
…n replacePaths
Sort strings so longer strings are handled first, so the longer
paths aren't mistakenly given a hash of some shorter substring path.
Add global flag to replacePaths regex to ensure all instances of a path
are handled.
…hs (#25)
Sort strings so longer strings are handled first, so the longer
paths aren't mistakenly given a hash of some shorter substring path.
Add global flag to replacePaths regex to ensure all instances of a path
are handled.
Hey there, I find staticify real handy in a prebuild and deploy scenario, there's just a few issues with
replacePaths
that mean it doesn't currently work completely for my use case:Consider CSS that looks like this, if Object.keys returns the
woff
path before thewoff2
path, the hash for the.woff
path will actually end up on the.woff2
, meaning a broken link in production.Should be easily fixed with a length sort of
Object.keys(versions)
, so longer strings get handled before shorter strings.Usually not an issue in my builds, but if a file is referenced more than once
replacePaths
won't currently pick it up. Better to turn it into anew RegExp(url, "g")
, the global flag will ensure it gets everything.I think this code should fit the bill but I didn't want to create a pull request and be presumptive, let me know if you want me to create one.
Cheers!
The text was updated successfully, but these errors were encountered: