From 96fb851b680d7279e7d7572e90e05de046dcaea6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ondr=CC=8Cej=20Ny=CC=81vlt?= Date: Mon, 21 Aug 2023 14:56:12 +0200 Subject: [PATCH] Serve CSS with version hash --- .gitignore | 2 ++ view/app.py | 4 ++++ view/requirements.txt | 3 ++- view/templates/base.html | 7 +++---- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index dda77fa..a5610af 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ data/diffs.db *.pyc node_modules .env +/view/static/dist +.webassets-cache diff --git a/view/app.py b/view/app.py index 5cd89f2..47d5685 100644 --- a/view/app.py +++ b/view/app.py @@ -3,6 +3,7 @@ import sqlite3 from flask import Flask, make_response, request, render_template, g, send_from_directory from flask_paginate import Pagination, get_page_parameter +from flask_assets import Environment import confuse import re @@ -15,6 +16,9 @@ config.set_file(CONFIG_FILE) app = Flask(__name__) +assets = Environment(app) +assets.register("css", "main.css", output="dist/main.%(version)s.css") +assets.url_expire = False def get_db(): diff --git a/view/requirements.txt b/view/requirements.txt index 05f5821..8fabd4d 100644 --- a/view/requirements.txt +++ b/view/requirements.txt @@ -1,3 +1,4 @@ flask flask-paginate -confuse \ No newline at end of file +confuse +Flask-Assets diff --git a/view/templates/base.html b/view/templates/base.html index b7ad844..3d59f58 100644 --- a/view/templates/base.html +++ b/view/templates/base.html @@ -4,10 +4,9 @@ Headline - + {% assets "css" %} + + {% endassets %}