mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-07 10:04:07 +00:00
update setup.py css build step for scss
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
},
|
||||
"scripts": {
|
||||
"postinstall": "python3 ./bower-lite",
|
||||
"css": "sass -I share/jupyterhub/static/components --source-map share/jupyterhub/static/scss/style.scss:share/jupyterhub/static/css/style.css"
|
||||
"css": "sass --style compressed -I share/jupyterhub/static/components --source-map share/jupyterhub/static/scss/style.scss:share/jupyterhub/static/css/style.min.css"
|
||||
},
|
||||
"devDependencies": {
|
||||
"sass": "^1.74.1"
|
||||
|
45
setup.py
45
setup.py
@@ -113,27 +113,34 @@ class NPM(BaseCommand):
|
||||
|
||||
|
||||
class CSS(BaseCommand):
|
||||
description = "compile CSS from LESS"
|
||||
description = "compile CSS"
|
||||
|
||||
def should_run(self):
|
||||
"""Does less need to run?"""
|
||||
# from IPython.html.tasks.py
|
||||
|
||||
"""Does CSS need to run?"""
|
||||
css_targets = [pjoin(static, 'css', 'style.min.css')]
|
||||
css_maps = [t + '.map' for t in css_targets]
|
||||
targets = css_targets + css_maps
|
||||
if not all(os.path.exists(t) for t in targets):
|
||||
# some generated files don't exist
|
||||
return True
|
||||
earliest_target = sorted(mtime(t) for t in targets)[0]
|
||||
earliest_target_mtime = float('inf')
|
||||
earliest_target_name = ''
|
||||
for t in targets:
|
||||
if not os.path.exists(t):
|
||||
print(f"Need to build css target: {t}")
|
||||
return True
|
||||
target_mtime = mtime(t)
|
||||
if target_mtime < earliest_target_mtime:
|
||||
earliest_target_name = t
|
||||
earliest_target_mtime = target_mtime
|
||||
|
||||
# check if any .less files are newer than the generated targets
|
||||
# check if any .scss files are newer than the generated targets
|
||||
for dirpath, dirnames, filenames in os.walk(static):
|
||||
for f in filenames:
|
||||
if f.endswith('.less'):
|
||||
if f.endswith('.scss'):
|
||||
path = pjoin(static, dirpath, f)
|
||||
timestamp = mtime(path)
|
||||
if timestamp > earliest_target:
|
||||
if timestamp > earliest_target_mtime:
|
||||
print(
|
||||
f"mtime for {path} > {earliest_target_name}, needs update"
|
||||
)
|
||||
return True
|
||||
|
||||
return False
|
||||
@@ -144,26 +151,18 @@ class CSS(BaseCommand):
|
||||
return
|
||||
|
||||
self.run_command('js')
|
||||
print("Building css with less")
|
||||
print("Building css")
|
||||
|
||||
style_less = pjoin(static, 'scss', 'style.scss')
|
||||
style_css = pjoin(static, 'css', 'style.min.css')
|
||||
sourcemap = style_css + '.map'
|
||||
|
||||
args = [
|
||||
'npm',
|
||||
'run',
|
||||
'css',
|
||||
]
|
||||
args = ['npm', 'run', 'css']
|
||||
try:
|
||||
check_call(args, cwd=here, shell=shell)
|
||||
except OSError as e:
|
||||
print("Failed to run lessc: %s" % e, file=sys.stderr)
|
||||
print("Failed to build css: %s" % e, file=sys.stderr)
|
||||
print("You can install js dependencies with `npm install`", file=sys.stderr)
|
||||
raise
|
||||
# update data-files in case this created new files
|
||||
self.distribution.data_files = get_data_files()
|
||||
assert not self.should_run(), 'CSS.run failed'
|
||||
assert not self.should_run(), 'CSS.run did not produce up-to-date output'
|
||||
|
||||
|
||||
class JSX(BaseCommand):
|
||||
|
@@ -32,7 +32,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
{% block stylesheet %}
|
||||
<link rel="stylesheet" href="{{ static_url("css/style.css") }}" type="text/css"/>
|
||||
<link rel="stylesheet" href="{{ static_url("css/style.min.css") }}" type="text/css"/>
|
||||
{% endblock %}
|
||||
{% block favicon %}
|
||||
<link rel="icon" href="{{ static_url("favicon.ico") }}" type="image/x-icon">
|
||||
|
Reference in New Issue
Block a user