Skip to content

Use md5 of compiled output content for filename #55

Open
@kevin1

Description

@kevin1

I am wondering if jekyll-asset-pipeline should name files based on the hash of output content, rather than the hash of pipeline parameters. This would ensure that cachebusting always works even if the asset converter is not hermetic. (This cachebusting strategy is also used by webpack.)

Currently the hash is computed by this code:

Digest::MD5.hexdigest(YAML.safe_load(manifest).map! do |path|
"#{path}#{File.mtime(File.join(source, path)).to_i}"
end.join.concat(options.to_s))

A non-hermetic build example is compiling a SASS file that imports partials. If I have these two files:

colors.scss (not known to jekyll-asset-pipeline)

$my-color: blue;

main.scss (included in some pipeline)

@use "colors";
.foo {
  color: $my-color;
}

modifying colors.scss results in jekyll-assets-pipeline generating a file with the same hash, despite affecting the content of the output css.

I could prepare a PR if there is interest in changing the hash behavior. Thanks!

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