Open
Description
I've looked through the issues, but couldn't find something similar. The below code used to work in less 2.x.
const less = require('less');
const raw = ` @import url('https://fonts.googleapis.com/css?family=Open+Sans:400,700');`;
less.render(raw, { processImports: false })
.then(() => console.info('Less ok!'))
.catch(error => console.error('Less failed!', error));
When trying this with less 3.11.1 it fails with TypeError: Cannot read property 'rules' of undefined
on the following less-code from less.cjs.js
:
else {
ruleset = new Ruleset(null, copyArray(this.root.rules));
ruleset.evalImports(context);
return this.features ? new Media(ruleset.rules, this.features.value) : ruleset.rules;
}
this.root
seems to be undefined
. I'm just wondering if it's something I did wrong on my end or that it's a bug we can fix?
Setting processImports to true > Ok
Adding more css/less > Same error.
Managed to fix it by changing the less code to
else if (this.root) {
ruleset = new Ruleset(null, copyArray(this.root.rules));
ruleset.evalImports(context);
return this.features ? new Media(ruleset.rules, this.features.value) : ruleset.rules;
} else { return []; }
But I'm not sure if that's the best approach here, there might be an underlying bug somewhere.