diff options
| author | Daniel Micay <danielmicay@gmail.com> | 2021-11-26 19:41:37 -0500 |
|---|---|---|
| committer | Daniel Micay <danielmicay@gmail.com> | 2021-11-26 19:41:37 -0500 |
| commit | 4027afcf6ec0a1dad3c260e3ece565cd2efe6b43 (patch) | |
| tree | 75cd0651c3bc74975c674837227abe501e89b929 /process-static | |
| parent | 23e42eabdfc701388c304360cf7bf5a7f272a7bc (diff) | |
add integrity metadata to preload header
Diffstat (limited to 'process-static')
| -rwxr-xr-x | process-static | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/process-static b/process-static index ac809e0d..307dc9ed 100755 --- a/process-static +++ b/process-static @@ -27,17 +27,17 @@ find static-tmp -name '*.js' -exec terser --ecma 2021 --module -cmo {} {} \; replace="" for file in static-tmp/**/*.css static-tmp/js/*.js static-tmp/mask-icon.svg; do hash=$(sha256sum "$file" | head -c 8) + sri_hash=sha256-$(openssl dgst -sha256 -binary "$file" | openssl base64 -A) dest="$(dirname $file)/$hash.$(basename $file)" if [[ $file == *.css ]]; then - sri_hash=sha256-$(openssl dgst -sha256 -binary "$file" | openssl base64 -A) replace+=";s@{{css|/${file#*/}}}@<link rel=\"stylesheet\" href=\"/${dest#*/}\" integrity=\"$sri_hash\"/>@g" elif [[ $file == *.js ]]; then - sri_hash=sha256-$(openssl dgst -sha256 -binary "$file" | openssl base64 -A) replace+=";s@{{js|/${file#*/}}}@<script type=\"module\" src=\"/${dest#*/}\" integrity=\"$sri_hash\"></script>@g" fi mv "$file" "$dest" + replace+=";s@{{integrity|/${file#*/}}}@${sri_hash}@g" replace+=";s@{{path|/${file#*/}}}@/${dest#*/}@g" done |
