less-vars-to-js icon indicating copy to clipboard operation
less-vars-to-js copied to clipboard

Keep original comments from less file

Open kriku opened this issue 6 years ago • 0 comments

It'll be useful to keep original comments when doing customization.

I mean in example like this, I have to use less-loader modifyVars to customize theme.. It could be like:

// webpack configuration
const paletteLess = fs.readFileSync(LESS_FILE, 'utf8');
const palette = lessToJs(paletteLess);
... 
// less-loader options
    ...    modifyVars: palette
...

In this case I don't work with js object directly, but also I couldn't set variables in less file with js functions... So I prefer use lessToJs explicitly, to form js file, then I can use nodejs and webpack power for doing different tricks:

// palette.js
const colors = require('./colors.json');

module.exports = {
    '@normal-color': colors['Light Black'],
    '@primary-color': colors['Blue'],
    // and all power of importing JSON to variables, or js functions and so on
};

Trick with colors.json in particular, caused by the inability import es modules from react-app to webpack configuration, but it fine to import json in both...

But anyway, it would be helpful if you add option to save original comments from less file.

kriku avatar Oct 20 '18 12:10 kriku