11# Copyright: 2022, ECP, NLnet Labs and the Internet.nl contributors
22# SPDX-License-Identifier: Apache-2.0
33from argparse import ArgumentParser
4- import io
54import os
65from uuid import uuid4 as uuid
76
87import rjsmin
9- import sass
108
119
1210FRONTEND_FOLDER = "frontend"
1513
1614DJANGO_STATIC_FOLDER = "static_frontend"
1715DJANGO_STATIC_JS_FOLDER = DJANGO_STATIC_FOLDER + "/js"
18- DJANGO_STATIC_CSS_FOLDER = DJANGO_STATIC_FOLDER + "/css"
1916
2017
2118def build_js (args = None ):
@@ -53,36 +50,6 @@ def build_js(args=None):
5350 print ("Done!" )
5451
5552
56- def build_css (args = None ):
57- """
58- Build/minify CSS and copy into Django's static folder.
59-
60- """
61- print ("-" * 20 )
62- print ("Building CSS files." )
63- try :
64- os .mkdir (DJANGO_STATIC_CSS_FOLDER )
65- except FileExistsError :
66- pass
67- for root , dirs , files in os .walk (FRONTEND_CSS_FOLDER ):
68- for filename in files :
69- if filename .endswith (".css" ):
70- if filename == "style.css-notyet-scss" :
71- continue
72- print (f"Found { filename } ..." )
73- filepath = os .path .join (root , filename )
74- content_min = sass .compile (
75- filename = filepath , output_style = "compressed" )
76- filename , _ = filename .rsplit ("." , 1 )
77- filepath = os .path .join (
78- DJANGO_STATIC_CSS_FOLDER , filename + "-min.css" )
79- print (f"... minifying to { filepath } " )
80- with open (filepath , 'w' , encoding = "utf-8" ) as f :
81- f .write (content_min )
82- break
83- print ("Done!" )
84-
85-
8653def parse ():
8754 """
8855 Parse the command line.
@@ -98,9 +65,6 @@ def parse():
9865
9966 parser .set_defaults (func = lambda x : parser .print_help ())
10067
101- to_django = subparsers .add_parser ('css' )
102- to_django .set_defaults (func = build_css )
103-
10468 to_tar = subparsers .add_parser ('js' )
10569 to_tar .set_defaults (func = build_js )
10670
0 commit comments