From 9c873e147c617db06b5b7e591fd6f9e796954b4e Mon Sep 17 00:00:00 2001 From: Kyle McCormick Date: Thu, 18 May 2023 16:56:52 -0400 Subject: [PATCH] build: stop suffixing XModule SCSS with hashes Similar to https://github.com/openedx/edx-platform/pull/32287, this change removes another unnecessary step from the `xmodule_assets` script. The script, which generates XModule SCSS "entrypoint" files (synthesizing one or more "source" SCSS resources), was appending MD5 hashes to each SCSS entrypoint filename: common/static/xmodule/descriptors/scss: AboutBlockStudio.768623f4d8d73dfb637fc94583adb990.scss ... WordCloudBlockStudio.d41d8cd98f00b204e9800998ecf8427e.scss common/static/xmodule/modules/scss: AboutBlockPreview.05a6cbd5c10100a245fa2cbf151b9770.scss ... WordCloudBlockPreview.7b899a56a70d29c58cf14b7e1888a0ec.scss It's unclear why these MD5 hashes needed to be appended. A comment in xmodule/static_content.py hints that it might have something to do with de-duplication, but that doesn't make any sense, because each XModule has exactly two SCSS entrypoint files (one for studio_view and one for other student/author_views) and none of those entrypoint files can possibly be shared between XModules. Soon, as part of deleting the `xmodule_assets` script, we would like to just check these SCSS files into version control rather than generating them. In order to do that, we will need to drop the hashes. This commit does that. The new output looks like this: common/static/xmodule/descriptors: AboutBlockStudio.scss ... WordCloudBlockStudio.scss common/static/xmodule/modules: AboutBlockPreview.scss ... WordCloudBlockPreview.scss Part of: https://github.com/openedx/edx-platform/issues/32292 --- xmodule/static_content.py | 3 +-- xmodule/util/xmodule_django.py | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/xmodule/static_content.py b/xmodule/static_content.py index 57eb8ce23487..a89ab1bf3b31 100755 --- a/xmodule/static_content.py +++ b/xmodule/static_content.py @@ -150,9 +150,8 @@ def _write_styles(selector, output_root, classes, css_attribute, suffix): )) module_styles_lines.extend(f' @import "{name}";' for name in fragment_names) module_styles_lines.append('}') - file_hash = hashlib.md5("".join(fragment_names).encode('ascii')).hexdigest() - contents[f"{class_.__name__}{suffix}.{file_hash}.scss"] = '\n'.join(module_styles_lines) + contents[f"{class_.__name__}{suffix}.scss"] = '\n'.join(module_styles_lines) _write_files(output_root, contents) diff --git a/xmodule/util/xmodule_django.py b/xmodule/util/xmodule_django.py index 248e10bf981a..1d9a858ea495 100644 --- a/xmodule/util/xmodule_django.py +++ b/xmodule/util/xmodule_django.py @@ -61,9 +61,9 @@ def load_assets(self): 'path': '/openedx/edx-platform/common/static/bundles/AnnotatableBlockPreview.js.map' }, { - 'name': 'AnnotatableBlockPreview.85745121.css', - 'path': 'common/static/css/xmodule/AnnotatableBlockPreview.85745121.css', - 'publicPath': '/static/css/xmodule/AnnotatableBlockPreview.85745121.css' + 'name': 'AnnotatableBlockPreview.css', + 'path': 'common/static/css/xmodule/AnnotatableBlockPreview.css', + 'publicPath': '/static/css/xmodule/AnnotatableBlockPreview.css' } ], ...