Skip to content

Commit

Permalink
add integrity hash for index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskthomas authored Jun 30, 2024
1 parent 4da78df commit 9a1cf11
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 11 additions & 6 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
#!/bin/sh

set -e

# Clean environment
rm -rf dist

# Build
mkdir dist
php src/index.php | minify --type html -o dist/index.html
minify -o dist/default.css src/default.css
minify -o dist/index.js src/index.js
mkdir dist && cd dist

# Minify static assets
minify -o default.css ../src/default.css
minify -o index.js ../src/index.js

# Copy other assets
cp src/api.php dist/api.php
cp src/template.php dist/template.php
cp ../src/api.php ../src/template.php ./

# Compile PHP and minify
php ../src/index.php | minify --type html -o index.html
2 changes: 1 addition & 1 deletion src/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
<ion-icon name="eye"></ion-icon> Preview
</button>
<div id="previewBlock" class="offcanvas offcanvas-end z-1"></div>
<script src="./index.js"></script>
<script src="index.js" integrity="sha384-<?= base64_encode(hash_file("sha384", "index.js", true)) ?>"></script>

<script type="module" src="<?= $ionicons_source ?>/dist/ionicons/ionicons.esm.js"></script>
<script nomodule src="<?= $ionicons_source ?>/dist/ionicons/ionicons.js"></script>
Expand Down

0 comments on commit 9a1cf11

Please sign in to comment.