Serve CSS with version hash

This commit is contained in:
Ondřej 2023-08-21 14:56:12 +02:00
parent edec2f4120
commit 96fb851b68
4 changed files with 11 additions and 5 deletions

2
.gitignore vendored
View file

@ -5,3 +5,5 @@ data/diffs.db
*.pyc
node_modules
.env
/view/static/dist
.webassets-cache

View file

@ -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():

View file

@ -1,3 +1,4 @@
flask
flask-paginate
confuse
Flask-Assets

View file

@ -4,10 +4,9 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Headline</title>
<link
rel="stylesheet"
href="{{ url_for('static', filename='main.css') }}"
/>
{% assets "css" %}
<link rel="stylesheet" href="{{ ASSET_URL }}" />
{% endassets %}
<link rel="icon" type="image/png" href="/static/icon-32.png" sizes="32x32" />
<link rel="icon" type="image/svg+xml" href="/static/icon.svg" />
<link rel="apple-touch-icon" href="/static/icon-180.png" />