Reorganize our CSS for cleanup and to resolve Django 4.2 build errors.

Review Request #13626 — Created March 9, 2024 and updated — Latest diff uploaded

Information

Djblets
release-5.x

Reviewers

Django 4.x changed the post-processing rules for CSS and JavaScript to
look for sourceMappingURL lines, with the goal of normalizing them to
include the hashes in the filename. This ended up breaking us.

In our built source files (those that go into a resulting bundle file),
sourceMappingURL entries are relative to the actual source file. So,
djblets/css/foo/bar.css would have a sourceMappingURL=bar.css.map,
which would live in djblets/css/foo.

When it came time to bundling, the source files would be concatenated
into the resulting file (say, djblets/css/foo.css). This would still
have relative references to the map files, but these wouldn't be updated
to point to where they actually live, instead claiming to be relative to
the resulting bundle file. This then led to the failure during
post-processing.

We're making some changes going forward to address this.

CSS bundle files will now be built from a corresponding .less file in
the same directory, always. We'll never have more than one file listed
in a bundle's source_filenames.

This bundle source file will do imports of a <bundledir>/index.less,
which will contain our own source files. It may also do an import of
another needed path (such as one from node_modules or lib).

This keeps things nicely separated and maintainable, and gives us a
clear pattern going forward for where files should live, fixing some
issues we have today.

The core issue still remains, and may impact extensions. The proper
solution will be URL rewriting in Pipeline, but that'll take a
contribution and new release.

Note, aside from import updates, no CSS/Less has been modified in this
change. Due to the repurposing of some filenames, Git will treat some of
this as whole-file replacements and new file additions.

Successfully built the Djblets package with no errors.

Commits

Files

    Loading...