0
点赞
收藏
分享

微信扫一扫

【GitLab】-HTTP 500 curl 22 The requested URL returned error: 500~SSH解决

小暴龙要抱抱 2023-11-18 阅读 25

less-vars-to-js 是一个用于将 LESS 变量转换为 JavaScript 对象的工具。它可以帮助你在使用 LESS 编写样式的同时,可以方便地在 JavaScript 代码中使用这些变量。

文档

  • https://www.npmjs.com/package/less-vars-to-js

安装

npm install less-vars-to-js -D

参数说明

参数说明
resolveVariablesResolves variables when they are defined in the same file.
dictionaryWhen resolveVariables is true, passes an object to use when the value cannot be resolved in the same file.
stripPrefixRemoves the @ or $ in the returned object keys.

示例

import lessToJs from "less-vars-to-js";
import fs from "fs";

// 将less文件读取到字符串
const paletteLess = fs.readFileSync("vars.less", "utf8");

// 解析less变量
const palette = lessToJs(paletteLess, {
  resolveVariables: true,
  stripPrefix: true,
});

console.log(palette);
// { blue: '#0d3880', pink: '#e60278' }
举报

相关推荐

0 条评论