This repository has been archived by the owner on Dec 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatic_assets.py
67 lines (54 loc) · 1.99 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
"""Compile static assets."""
import os
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"):
app = app or Flask(__name__, static_folder=static_folder)
with app.app_context():
env = Environment(app)
env.load_path = [
path.join(path.dirname(__file__), "assess/static/src"),
path.join(path.dirname(__file__), "authenticator/frontend/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(
"./assess/js/namespaces.js",
"./assess/js/helpers.js",
"./assess/js/all.js",
"./assess/js/components/*/*.js",
"./assess/js/init.js",
filters="jsmin",
output="assess/js/main.min.js",
)
css = Bundle(
"./assess/css/*.css",
filters="cssmin",
output="assess/css/main.min.css",
extra={"rel": "stylesheet/css"},
)
authenticator_js = Bundle(
"./authenticator/js/namespaces.js",
"./authenticator/js/helpers.js",
"./authenticator/js/all.js",
"./authenticator/js/fsd_cookies.js",
"./authenticator/js/components/**/*.js",
filters="jsmin",
output="authenticator/js/main.min.js",
)
env.register("authenticator_main_js", authenticator_js)
env.register("default_styles", css)
env.register("main_js", js)
bundles = [authenticator_js, css, js]
return bundles
def build_bundles(static_folder="static"):
os.makedirs(static_folder, exist_ok=True)
bundles = init_assets(static_folder=static_folder)
for bundle in bundles:
bundle.build()
if __name__ == "__main__":
build_bundles()