solspace / craft-freeform

Freeform for Craft: The most reliable form builder that's ready for wherever your project takes you.
https://docs.solspace.com/craft/freeform/v5/
Other
48 stars 61 forks source link

Freeform formatting template resources are not Craft Cloud compatible #1660

Open timkelty opened 1 day ago

timkelty commented 1 day ago

What happened?

Craft Cloud requires that front-end resources be defined as asset bundles, so it can publish them to the CDN at deploy time.

Freeform ships with Formatting Templates that attempt to load CSS/JS via view.assetManager.publishedUrl, but because those are never defined as Asset Bundles, they are never copied to the CDN: https://github.com/solspace/craft-freeform/blob/v5/packages/plugin/src/templates/_templates/formatting/flexbox/index.twig#L2-L3

The result is a URL to something like: https://cdn.craft.cloud/{envId}/builds/{buildId}/cpresources/Solspace-Freeform-templates-_templates-formatting-flexbox/_main.css which will be a 404.

The most straightforward way to address this would probably be to move the referenced assets to packages/plugin/src/Resources/{css,js} and a corresponding \Solspace\Freeform\Resources\Bundles\TemplateBundle`.

Errors and Stack Trace (if available)

No response

How can we reproduce this?

Render a form using a formatting template that includes resources, eg flexbox.

Freeform Edition

Pro

Freeform Version

5.6.8

Craft Version

5.4.9

When did this issue start?

No response

Previous Freeform Version

No response

kjmartens commented 20 hours ago

Thank you for bringing this to our attention @timkelty.

We'll look into this and address it shortly. 🙂