electron-compile icon indicating copy to clipboard operation
electron-compile copied to clipboard

Dynamically Adding Less Styles

Open eric1234 opened this issue 8 years ago • 0 comments

The HTML in my app is the same regardless of window since I am using React components. To avoid a lot of dummy HTML files that are pretty much the same I have one that is dynamically told what component to load. The code in the HTML file looks a bit like:

let Component = require(`${__dirname}/../views/${view}`).default
let component = ReactDOM.render(<Component />, document.getElementsByTagName('body')[0])

This is working great except when it comes to stylesheets using Less. I can successfully hard-code a Less link and it compiles correctly. I can also dynamically include a link to a regular CSS file. But if I try to dynamically add a link to a less file it doesn't seem to load the CSS. How can I dynamically inject a Less stylesheet and have it pre-compile?

I did see this comment which indicates it is possible but that isn't the experience I get.

eric1234 avatar May 10 '17 13:05 eric1234