I’d like to use a CSS framework (Semantic-UI) for one of my routes/components, but if I leave it permanently it messes with the layout of other routes/pages I’ve already built without it.
Is there an “elegant” way to load in or “activate” a CSS file on route change and then remove it again upon another route change?
If anyone else finds this, I got it to work by including both the as="scoped" attribute on my css require and adding the @useShadowDOM decorator on my view model (so at least for me it wasn’t quite the either/or mentioned above). Works in both Firefox and Chrome.
Doing so allows me to import a CSS file (hand-written or from a library like Bootstrap, Materialize, or Fomantic) for just that component and not have it stick around to pollute further components when I route to them afterwards.
I couldn’t because the CSS I wanted to have scoped were library files (Materialize and Fomantic). And my hand-written CSS is in Stylus, so I wouldn’t be able to inline it anyway (so far as I’m aware, using Webpack). But thanks for getting me 95% of the way there!