I was just working on improving https://github.com/unhurdle/spectrum-royale/tree/include-css
Basically, for the Spectrum components to work, there is CSS which needs to be included in the application. Spectrum divides the css into components, so you can include only the CSS you need for specific components. I modified all the classes to use inject_html to add headers for each of the CSS files needed for each component. This now works (with some caveats which I’m not going into here). I ran into a few issues while doing this which I wanted to discuss here: 1. inject_html is a bit “fragile” in that it only works if the comment is immediately proceeding the constructor. 2. If you have multiple classes which require the same css file, you get a <link> for each class even though it’s required once. 3. This ends up with many small css files linked in the app. This can make for slower startup times for apps loaded using HTML/1.1. 4. The only way I was able to get this to work was by having a rigid folder structure that all apps using the library adhere to. Ideally, here’s what I would like to do: 1. Have a way of declaring that a class requires a specific CSS file. 2. Include all the possibly required CSS files in the lib swc. 3. When the css for the app is compiled, the required css files should be concatenated to the main app CSS (and minified) Any ideas on how to achieve this goal and thoughts on how hard it would be? Thanks, Harbs
