Hi Haydn.
I have just tested this myself and it is possible currently, but there are a few caveats.
To start with ,to reference the original comment, we still don’t support loading SCSS files from either external or outside of the CS widget.
You can however import an external CSS file into a component by doing:
@import url("https://mydomain.com/mytheme.css");
This will then load the file from the URL when the page with that component is loaded, but it’s worth noting that CSS files are imported regardless of whether the component is actually loaded, therefore any CSS files you import have the potential to change the styling of the entire interface.
There are two ways to host the CSS;
External Domain / CDN
You can host the CSS file on an external domain or CDN and then import it like the above code does, but the only thing you’d need to do is go to the interface firewall rules, and add the domain to the “Domains that can contribute content to the liberty create application” and make sure to check the CSS option, for example, the URL in my example above, you would need to add mydomain.com
to the above.
This will then load, I tested this on my current application and it works fine, but as I noted above, the library I included (bulma) changed, and broke, some of the layout of my interface page.
Hosting via Create
So you can’t upload an asset file or anything to that effect, because asset files are returned as plain text, for security reasons, meaning if you were to try and load this file, the browser would not be able to understand the file type when loaded.
You can however create a Code Studio widget that simply contains a load of SCSS files, (you can remove the content of the .js, .htm files), and when you compile it will generate a .css
file that you can import, meaning you can utilise SCSS and nicely split files up and import them however you need, meaning one component becomes a “library”.
Once you have done that and compiled/published it, you can find the URL and it should look something like:
https://your-app-name.oncreate.app/assets/code_studio/<codeStudioId>/<codeStudioId>.css
You can then put that full URL into the @import url(...)
statement and it will load.
The caveat with this method is that, you will need the full URL, because by trying to just put the /path/to/file.css
it will try and find a file relative from it’s location, which won’t work due to permissions, so you would need a full URL, and of course you’d then need to deal with each environment of that URL.
It’s worth adding though that, you can add your own SCSS via theme packs or via the stylesheets which can contain SCSS/CSS which can be loaded into the application as a whole, you could create a set of “helper” CSS/SCSS that is loaded into each page with classes. You can then add the classes to your code studio components and use them that way, especially if you are intending to use the same CSS/SCSS across multiple components.
I hope that helps, let me know if you need any further information.