generated from communitiesuk/funding-service-design-TEMPLATE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatic_assets.py
34 lines (24 loc) · 1.01 KB
/
static_assets.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""Compile static assets."""
from os import path
from flask import Flask
from flask_assets import Bundle, Environment
def init_assets(app=None, auto_build=False, static_folder="static/src"):
app = app or Flask(__name__)
app.static_folder = static_folder
with app.app_context():
env = Environment(app)
env.load_path = [path.join(path.dirname(__file__), "static")]
# Packeto doesn't support automatic rebuilding.
env.auto_build = auto_build
# This file needs to be shipped with your code.
env.manifest = "file"
js = Bundle("src/js/*.js", filters="jsmin", output="dist/js/custom-%(version)s.min.js")
css = Bundle(Bundle("src/css/*.css", filters="cssmin", output="dist/css/custom-%(version)s.min.css"))
env.register("js", js)
env.register("css", css)
bundles = [css, js]
return bundles
def build_bundles(static_folder):
bundles = init_assets(static_folder=static_folder)
for bundle in bundles:
bundle.build()