Use flask-webassets to version js/css bundle

This commit is contained in:
Patrick Smith 2018-08-02 14:54:07 -04:00
parent b67b4cca44
commit dea0962f7c
3 changed files with 15 additions and 7 deletions

View File

@ -4,10 +4,14 @@ from atst.home import home
environment = Environment()
css = Bundle(
"../scss/atat.scss",
filters="scss",
output="../static/assets/out.%(version)s.css",
depends=("**/*.scss"),
"../static/assets/index.css",
output="../static/assets/styles.%(version)s.css",
)
environment.register("css", css)
js = Bundle(
'../static/assets/index.js',
output='../static/assets/index.%(version)s.js'
)
environment.register('js_all', js)

View File

@ -5,7 +5,7 @@
"main": "index.js",
"scripts": {
"watch": "parcel watch static/js/index.js -d static/assets -o index.js --no-autoinstall",
"build": "parcel build static/js/index.js -d static/assets -o index.js --no-autoinstall",
"build": "parcel build static/js/index.js -d static/assets -o index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",

View File

@ -8,7 +8,9 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>{% block title %}JEDI{% endblock %}</title>
<link rel="stylesheet" href="{{ url_for('static', filename='assets/index.css') }}">
{% assets "css" %}
<link rel="stylesheet" href="{{ ASSET_URL }}" type="text/css">
{% endassets %}
<link rel="icon" type="image/x-icon" href="/static/img/favicon.ico">
</head>
<body class="{% if g.modalOpen %} modalOpen{% endif %}">
@ -32,6 +34,8 @@
{% include 'footer.html' %}
{% block modal %}{% endblock %}
<script src="{{ url_for('static', filename='assets/index.js') }}"></script>
{% assets "js_all" %}
<script src="{{ ASSET_URL }}"/>
{% endassets %}
</body>
</html>