Having a single variable that specifies a color within a variables.less
file (e.g. @themeColor: #B30F55;
), and a .json
file that constitutes a list of entities, where each key is an entity ID and the value of the key is that entity's color (e.g. '8ab834f32' : '#B30F55', '3cc734f31' : '#99981F'
), how could I run a Grunt task that outputs as many independent CSS files as there are entities in the json, after substituting the variable value?
相关问题
- Adding a timeout to a render function in ReactJS
-
Why does the box-shadow property not apply to a
- Add animation to jQuery function Interval
- jQuery hover to slide?
- Issue with star rating css
You can define a different task for each color. grunt-contrib-less supports the Modifyvars option:
You can set
modifyVars: themeColor={yourcolor}
for each taskSee: Grunt - read json object from file
An other example can be found at Dynamic Build Processes with Grunt.js
example
colors.json:
Gruntfile.js:
less/main.less:
than run
grunt
:cat dist/css/3cc734f31.css: