在命令行上提供 sass 变量定义 [英] Provide sass variables definitions on command-line

查看:41
本文介绍了在命令行上提供 sass 变量定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种标准的或简单的方法可以在命令行上定义 sass 变量,或者从环境中传递它们?我正在做的是尝试从单个 SCSS 源文件创建不同的 CSS 文件.每个输出文件都将专门用于某个目标设备,并包含在带有媒体查询的 HTML 页面中.

Is there a standard, or simple, way to define sass variables on the command line, or pass them from the environment? What I am doing is trying to create to different CSS files from a single SCSS source file. Each output file will be specialized for a certain target device and included from the HTML page with media queries.

更新:看起来这可能还不够.@if 语法实际上不允许条件 sass 块,只允许条件 CSS 块.这意味着即使我可以定义一个变量,它也不允许我在文件中进行不同的处理.有什么想法吗?

Update: It looks like this may not be enough. The @if syntax doesn't actually allow conditional sass blocks, only conditional CSS blocks. This means even if I can define a variable it wouldn't allow me to do different processing in the file. Any ideas?

推荐答案

我需要的工具根本不在 SASS 中.即使您可以在命令行上定义变量,if"工具也不足以在样式表中实际执行条件块.

The facility I needed is simply not in SASS. Even if you could define variables on the command-line the "if" facility is insufficient to actually do conditional blocks in the style sheet.

相反,我求助于 M4 的旧备用.我只是用 M4 对 SASS 进行预处理,执行命令行选项和完整的条件块.

Instead I've resorted to the old stand-by of M4. I simply preprocess the SASS with M4, doing command-line options and full conditional blocks.

这篇关于在命令行上提供 sass 变量定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆