Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Steffen Hornbæk Nielsen 54 posts 165 karma points
    Jun 21, 2023 @ 11:45
    Steffen Hornbæk Nielsen

    Stylesheet persistence when redeploy

    Hi everyone,

    There might not be a solution to this, but here we go.

    I have a Umbraco 11 solution, where we are using the stylesheets for RTE stuff. But, when the out client make changes to the stylesheet directly through backoffice and we then make a new deploy to fix a issue, the content of the stylesheets are overridden.

    So i was wondering, if there are any smart way to persist the data in stylesheets, so it won't be affected if we deploy any new changes to the Backoffice.

    I was hoping we might be able to save the content in the database, and perhaps not even need to have the .css files directly in the solution directory.

  • Simon Napper 109 posts 343 karma points
    Jun 21, 2023 @ 12:55
    Simon Napper

    Happy for someone to correct me on this, but I don't think you can store the stylesheets in the database out of the box. The RTE uses the TinyMCE wysiwyg editor, which is a thing in its own right and I think that depends on physical stylesheets for the styling.

    I guess the obvious question would be if the client should really be making changes to the stylesheet file, as unless they keep you updated so you can update the file in your codebase (or you don't include it in your release, but you could be opening up a can of worms there) you're always going to overwrite it when you push the latest code up. If you give them access to the inline HTML editing in the rte, could they add their styles inline? That way they get stored as content and not overwritten when the code updates.

    Only other out there things I can think of, is to create your own editor or if you really want to get funky, some custom code that stores the css contents in a custom db table and overwrites the contents of the css file when Umbraco starts up.
    Not sure I'd recommend either of those really though!

  • Steffen Hornbæk Nielsen 54 posts 165 karma points
    Jun 22, 2023 @ 10:14
    Steffen Hornbæk Nielsen

    Thanks for the reply Simon :D

    I was hoping for a solution, but i cen see why this would be har to accomplish. Perhaps someday when i have time, i should make a package for this usecase.

    Just needed someone to tell me "no can do amigo" :D Thanks

  • Søren Kottal 706 posts 4503 karma points MVP 6x c-trib
    Jun 23, 2023 @ 09:50
    Søren Kottal

    Hi Steffen

    I usually add a stylesheet only for the RTE, where formats etc from Umbraco end up.

    I then import (using @imports) the actual styles into that. This way I can add formats and stuff in Umbraco, without messing with the stylesheet.

  • Steffen Hornbæk Nielsen 54 posts 165 karma points
    Aug 01, 2023 @ 12:31
    Steffen Hornbæk Nielsen

    Hi Søren,

    Started doing this, but here comes the next part. We have both staging and production environment's and this causes the url to be different from each environment.

    Does this mean that i have to have two identical css files in stylesheet (one called staging and one called production.css) and then refer to the correct url (media->css file)?

    Otherwise i will have to do some filetransformation on building the solution to each environment.

Please Sign in or register to post replies

Write your reply to: