• 
      

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

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

    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.

    Summary ID
    Reorganize our CSS for cleanup and to resolve Django 4.2 build errors.
    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.
    47de13538e54ce2a4f863933c8e973c488f26290
    Checks run (2 succeeded)
    flake8 passed.
    JSHint passed.
    david
    1. Ship It!
    2. 
        
    maubin
    1. Ship It!
    2.