The question is clearly understood from the title; in order not to leave the question text field empty, I will say why I need it. It is necessary to ensure that the same variables are available in both JavaScript and LESS (and therefore CSS ).

This approach can be applied, for example, with cross-platform layout, when you not only change the style through CSS media queries, but also change the layout as a whole, manipulating the DOM through JS ; In this case, it is convenient to set the minimum and maximum values ​​of the phases (window widths at which the layout does not change) in the JSON file, which will be read as LESS for the formation for media queries, and JS . T. o. JSON will play the role of the configuration file.

  • Do you need to work in the browser? - Vladimir Gamalyan
  • In sense that LESS took variables from JSON when loading the page? No, I use LESS only when developing a site, and a ready-made site uses only CSS. - Hokov Gleb
  • one
    Surely there is an appropriate plugin for your build system. For example for gulp : npmjs.com/package/gulp-less-json-variables - Vladimir Gamalyan

0