Skip to content

[3.x] Ensure assets publish appropriately - #201

Closed
brianjhanson wants to merge 1 commit into
3.xfrom
bugfix/publish-assets
Closed

brianjhanson wants to merge 1 commit into
3.xfrom
bugfix/publish-assets

Conversation

@brianjhanson

Copy link
Copy Markdown
Contributor

Adds $scripts config so the front end assets will publish.

@riasvdv / @AugustMiller if this isn't the preferred way to do this just let me know.

@AugustMiller

Copy link
Copy Markdown

To be honest, I hadn't considered that our AssetBundle shim lacked auto-publishing hooks. It would be nice to not have to define the source and destination paths in two places, and have the trait take care of normalizing asset bundles into $scripts and $styles. 😬

Checked out locally, and I'm seeing two copies of this injected on /admin/settings/filesystems/new:

  • /vendor/craftcms/aws-s3/js/edit-fs.js?v=de22d050da51d1e17dee9546258ec572 is loaded on every CP request (due to its presence in $scripts)
  • /vendor/craftcms/aws-s3/js/edit-fs.js is loaded because we explicitly add the asset bundle in Plugin::getSettingsHtml()

This is actually the opposite of what I figured would happen (I thought the asset bundle would be versioned)!

I'll wait for Rias to chime in—but my preference would be to have both of these flow through the same channel and get de-duped. Upstream change! 😈

@riasvdv

riasvdv commented Jul 17, 2026

Copy link
Copy Markdown

Using AssetBundles should still work just as before and is probably why you're seeing it loaded when getSettingsHtml is called.

Using $scripts is for adding the script to all CP requests, if you need to load something specifically on one page then the new way is to use the HtmlStack, this is also what the yii2-adapter now pushes into when asset bundles are registered.

There's no de-duping between legacy AssetBundles and things you push into HtmlStack though, that would get way too complicated for little benefit, you either still use AssetBundles with the adapater, or you move to using HtmlStack

For making sure it's published, you can instead add it to the $publishables property

@brianjhanson

Copy link
Copy Markdown
Contributor Author

I'm going to close this one for the moment. I was running into an issue where the edit-fs.js was throwing a 404 when loading the settings page. Specifically when another filesystem was selected at first, and you would switch to the S3 FS. Based on the comments, it sounds like that's probably not an issue with the plugin but elsewhere.

@brianjhanson

Copy link
Copy Markdown
Contributor Author

I take that back, I've moved from $scripts to $publishables because we do want to make sure that asset is published. @riasvdv it looks like AssetBundles alone aren't enough to publish assets, is that correct?

Or if they are enough, the plugin doesn't appear as a tag in the artisan publish command when the $publishables array isn't defined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants