electron-userland / electron-compile

DEPRECATED: Electron supporting package to compile JS and CSS in Electron applications
1.01k stars 99 forks source link

Dynamically Adding Less Styles #236

Open eric1234 opened 7 years ago

eric1234 commented 7 years ago

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.