Dynamic import of less stylesheets


All templates in my app are organised in individual html, js and less files. Where possible, templates are loaded dynamically (thanks to the wonderful FlowRouter Extra).

I “import” my less files all into a main.less. I’d rather load my less/css dynamically. Anyone know how to do this?



I just import the .less file into the main module. Once Meteor imports the main module, it loads the CSS with it.

import './style/style.styl';
1 Like

Thanks Max, if only all things in life could be this simple!

I did have to add an @import “/imports/mymixins.less” to several of my less files.

Put the import statement in the js file you are dynamically importing:

import './style.less

Then when you import that js module, the compiled less will also be imported and injected into the page as a new <style> tag