pip install Flask-Assets
python
from flask_assets import Environment, Bundle
assets = Environment(app)
app.config['STATIC_FOLDER'] = 'static'
app.config['ASSETS_FOLDER'] = 'static/build'
app.config['ASSETS_URL'] = '/static/build'
python
css_bundle = Bundle(
'css/bootstrap.css',
'css/style.css',
filters='cssmin',
output='css/style.min.css'
)
js_bundle = Bundle(
'js/jquery.js',
'js/bootstrap.js',
filters='jsmin',
output='js/app.min.js'
)
python
assets.register('css_all', css_bundle)
assets.register('js_all', js_bundle)
html
{% assets "css_all" %}
<link rel="stylesheet" href="{{ ASSET_URL }}">
{% endassets %}
{% assets "js_all" %}
<script src="{{ ASSET_URL }}"></script>
{% endassets %}