Best way to dynamically importing templates & stylesheets in Blaze?

Hi folks,

I’m working on a CMS like system where you pick from a list of templates to render on each page. Some of these templates are quite large and so I’m using dynamic imports to code split. The only thing I don’t get is how to import the styles for each module. The templates are currently provided by local packages since the code is shared between many apps.

I’d prefer not to have to include the styles for all possible templates in the bundle. And I’m not sure what happens to all the styles injected to the page when you import styles from javascript, especially after navigating around and loading a bunch of templates.

What is the best way to dynamically import styles for large templates / modules?

Im also curious if you can use named exports to import and load a Blaze template.

ie: instead of:
import 'meteor/foo:bar/templates/client/example';
I want to be able to
import { example } from 'meteor/foo:bar'

The question is what can I export to get this behaviour?

I haven’t test it yet. But I would made a .js file for each template that will import the HTML and the associated .CSS file.

Then I would load this .js file when needed.