Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The non-debug versions of certain static resources aren't loaded when Resource Debug Mode is set to Enabled #16401

Closed
Piedone opened this issue Jul 3, 2024 · 3 comments · Fixed by #16406
Labels

Comments

@Piedone
Copy link
Member

Piedone commented Jul 3, 2024

Describe the bug

Orchard Core version

4aeaaf9

To Reproduce

  1. Set up a site with the Blog recipe.
  2. Go to Configuration -> Settings -> General (by default https://localhost:44300/blog/Admin/Settings/general), and change Resource Debug Mode to Enabled (but "From environment", which sets the same when running locally, reproduces the same issue).
  3. Open the Article editor, by default under https://localhost:44300/Admin/Contents/ContentItems/4xg73tbftb4x8r31680zxesexv/Edit This is just an example, other pages are surely also affected.
  4. Notice how a lot of .min static resources are loaded, e.g. /TheAdmin/css/admin-layout.min.css, /OrchardCore.Resources/Scripts/jquery.min.js, and /OrchardCore.Resources/Scripts/trumbowyg/trumbowyg.min.js, despite all of these having non-minified debug versions configured. Not all resources are affected though, e.g. /OrchardCore.Html/Scripts/trumbowyg.media.tag.js and /OrchardCore.Resources/Scripts/trumbowyg/trumbowyg.shortcodes.js are correctly loaded as the debug versions.
  5. Change Resource Debug Mode to Disabled, reload the Article editor, and observe how correctly only minified resources are loaded.

Expected behavior

With Resource Debug Mode set to Enabled only the non-minified resources are loaded.

Logs and screenshots

Foot scripts with Resource Debug Mode enabled:

image

And disabled:

image

Head scripts and stylesheets enabled:

image

Disabled:

image

Notice how the affected foot scripts seem to all lack the cache-busting v query string parameter as well when Resource Debug Mode is set to Enabled, which is another, most possibly related issue. This is not so clearly the case for the head resources though.

@Piedone
Copy link
Member Author

Piedone commented Jul 3, 2024

This doesn't seem to be related to the resource having dependencies or not, being defined in a template or a config file, or TheAdmin lacking a dependency on OrchardCore.Resources.

@Piedone
Copy link
Member Author

Piedone commented Jul 3, 2024

From these, only admin-main is problematic:

            _manifest
                .DefineScript("admin")
                .SetDependencies("bootstrap", "admin-main", "theme-manager", "jQuery")
                .SetUrl("~/TheAdmin/js/TheAdmin.min.js", "~/TheAdmin/js/TheAdmin.js")
                .SetVersion("1.0.0");

            _manifest
                .DefineScript("admin-main")
                .SetUrl("~/TheAdmin/js/TheAdmin-main.min.js", "~/TheAdmin/js/TheAdmin-main.js")
                .SetDependencies("theme-head", "js-cookie")
                .SetVersion("1.0.0");

            _manifest
                .DefineStyle("admin")
                .SetUrl("~/TheAdmin/css/TheAdmin.min.css", "~/TheAdmin/css/TheAdmin.css")
                .SetVersion("1.0.0");

If I remove its dependencies and that of admin, it works fine too.

@Piedone
Copy link
Member Author

Piedone commented Jul 3, 2024

This is enough to reproduce the problem in src/OrchardCore.Themes/TheAdmin/ResourceManagementOptionsConfiguration.cs:

            _manifest
                .DefineScript("admin")
                .SetDependencies("admin-main")
                .SetUrl("~/TheAdmin/js/TheAdmin.min.js", "~/TheAdmin/js/TheAdmin.js")
                .SetVersion("1.0.0");

            _manifest
                .DefineScript("admin-main")
                .SetUrl("~/TheAdmin/js/TheAdmin-main.min.js", "~/TheAdmin/js/TheAdmin-main.js")
                .SetVersion("1.0.0");

            _manifest
                .DefineStyle("admin")
                .SetUrl("~/TheAdmin/css/TheAdmin.min.css", "~/TheAdmin/css/TheAdmin.css")
                .SetVersion("1.0.0");

/TheAdmin/js/TheAdmin-main.min.js will be loaded erroneously, while /TheAdmin/css/TheAdmin.css?v=g4LRBNgu1vjY9pK-tGOBO7fBCBWSt1eQxzkGbvkIaV0 and /TheAdmin/js/TheAdmin.js?v=2bDeSNHH4vC3IPP1mBWkhKH0wCNM-JJEVho3ulY838Y are correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant