We have a unique situation where our AEM content is reverse proxied into an HTML container. This outer container holds the <head> tags for the page, as well as all the CSS and JS calls for the site.
While authoring in AEM, I want to be able to use one of the CSS files to help authors see the final styling. I have a solution that is 90% of the way there, however, it fails when an author chooses the "View as published" option. I'm using this conditional statement:
<sly data-sly-test="${wcmmode.edit || wcmmode.preview}" data-sly-call="${clientlib.css @ categories='developer-portal.authoring'}"/>
This works for editing and the preview mode that's available on the editing page. I initially thought I could add in a condition for wcmmode.disabled, as the "view as published" mode sets the wccmmode.disabled cookie to "true." However, I've discovered that when you actually publish the page, the wcmmode.disabled cookie is also set to "true." So the CSS include gets added to the final page HTML, meaning that I now have two calls for the same CSS - one in the <head> of the container HTML, and one from my page template.
I'm hoping someone might have an idea of how to separate the "view as published" experience from the actual published experience. I haven't found any documentation, and the "view as published" option seems to bypass any connection to the authoring environment.