Skip to content

Commit

Permalink
compression : js, css + brotli
Browse files Browse the repository at this point in the history
  • Loading branch information
eyssette committed Aug 27, 2024
1 parent 662291a commit 7aa4b21
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 10 deletions.
19 changes: 13 additions & 6 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
variables:
FILES_TO_COMPRESS: "html js css ico"

pages:
image: alpine:latest
before_script:
- apk update && apk add gzip brotli
script:
- mkdir .public
- cp -r * .public
- mkdir -p .public .public/css .public/img
- cp favicon.ico index.html script.min.js style.min.css .public/
- cp img/* .public/img
- mv .public public
- find public -type f -regex '.*\.\(htm\|html\|txt\|text\|js\|css\)$' -exec gzip -f -k {} \;
- find public -type f -regex '.*\.\(htm\|html\|txt\|text\|js\|css\)$' -exec brotli -f -k {} \;
- for ext in $FILES_TO_COMPRESS; do find public -type f -name "*.$ext" -exec gzip -f -k {} \;; done
- for ext in $FILES_TO_COMPRESS; do find public -type f -name "*.$ext" -exec brotli -f -k {} \;; done
artifacts:
paths:
- public
only:
- master
rules:
- if: $CI_COMMIT_BRANCH == "master"
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<meta name="description" content="Sites et outils numériques proposés par Cédric Eyssette : cours de philosophie, formations pédagogiques, logiciels en ligne libres et gratuits souvent fondés sur l’utilisation du Markdown et hébergés sur la Forge" />
<title>Sites et outils numériques proposés par Cédric Eyssette : cours de philosophie, formations pédagogiques, logiciels en ligne libres et gratuits souvent fondés sur l’utilisation du Markdown et hébergés sur la Forge</title>
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="style.css" />
<link rel="stylesheet" href="style.min.css" />
</head>
<body>
<header>
Expand Down Expand Up @@ -253,6 +253,6 @@ <h3 id="dautres-petites-applications">D’autres petites applications</h3>
</div>
</main>
</section>
<script src="script.js"></script>
<script src="script.min.js"></script>
</body>
</html>
1 change: 1 addition & 0 deletions script.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
python3 scripts/add-nbsp-to-images-lines.py && pandoc -f markdown+lists_without_preceding_blankline+autolink_bare_uris -t html -s index.md -o index.html -c style.css --template=scripts/template.html
python3 scripts/add-nbsp-to-images-lines.py && pandoc -f markdown+lists_without_preceding_blankline+autolink_bare_uris -t html -s index.md -o index.html -c style.min.css --template=scripts/template.html
python3 scripts/change-html.py
2 changes: 1 addition & 1 deletion scripts/change-html.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def replace_img(match):
return html

def add_js(html):
html = html.replace("</body>",'<script src="script.js"></script>\n</body>')
html = html.replace("</body>",'<script src="script.min.js"></script>\n</body>')
return html

def main():
Expand Down
1 change: 1 addition & 0 deletions style.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7aa4b21

Please sign in to comment.