This repository has been archived by the owner on Dec 10, 2024. It is now read-only.
generated from communitiesuk/funding-service-design-TEMPLATE
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstatic_assets.py
52 lines (41 loc) · 1.46 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""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="app/static/dist"):
app = app or Flask(__name__)
app.static_folder = static_folder # config.Config.STATIC_FOLDER
# app.static_url_path = config.Config.STATIC_URL_PATH
with app.app_context():
env = Environment(app)
env.load_path = [path.join(path.dirname(__file__), "app/static/src")]
# env.set_directory(env_directory)
# App Engine doesn't support automatic rebuilding.
env.auto_build = auto_build
# This file needs to be shipped with your code.
env.manifest = "file"
js = Bundle(
"./js/namespaces.js",
"./js/helpers.js",
"./js/all.js",
"./js/components/*/*.js",
"./js/init.js",
filters="jsmin",
output="js/main.min.js",
)
css = Bundle(
"./css/*.css",
filters="cssmin",
output="css/main.min.css",
extra={"rel": "stylesheet/css"},
)
env.register("default_styles", css)
env.register("main_js", js)
bundles = [css, js]
return bundles
def build_bundles(static_folder="app/static/dist"):
bundles = init_assets(static_folder=static_folder)
for bundle in bundles:
bundle.build()
if __name__ == "__main__":
build_bundles()