diff --git a/package.json b/package.json index 606817a1..de5d8ca5 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/setup.py b/setup.py index 696819f0..3adbf2f4 100755 --- a/setup.py +++ b/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): diff --git a/share/jupyterhub/templates/page.html b/share/jupyterhub/templates/page.html index c2306013..a35b84ae 100644 --- a/share/jupyterhub/templates/page.html +++ b/share/jupyterhub/templates/page.html @@ -32,7 +32,7 @@ {% block stylesheet %} - + {% endblock %} {% block favicon %}