简体   繁体   English

如何将变量传递给 scss 处理器?

[英]How do I pass variables to scss processor?

My current set up is Front-end: VueJS我目前的设置是前端:VueJS

Backend Python, Tornado后端 Python,龙卷风

Vue is used using the cdn for indivudual static templates. Vue 使用 cdn 用于单个静态模板。 Tornado serves the templates. Tornado 提供模板。 I'm using the python scss library to compile the scss, that part of pretty straight forward.我正在使用 python scss 库来编译 scss,这部分非常简单。

sass.compile(dirname=(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'static/scss'), os.path.join(os.path.dirname(os.path.abspath(__file__)), 'static/css')), output_style='compressed')

I have two config.py files that hold configurations with two different color schemes among other things, I would like to use pass the color vars in those files to the scss file but don't know if there's a way/possible.我有两个 config.py 文件,其中包含具有两种不同配色方案的配置等,我想使用将这些文件中的颜色变量传递给 scss 文件,但不知道是否有办法/可能。

I can pass global variables to the templates using tornado but that's not what I need because the scss file has to get compiled using those colors before that happens.我可以使用 tornado 将全局变量传递给模板,但这不是我所需要的,因为 scss 文件必须在发生之前使用这些颜色进行编译。 I've done tons of research before this but can't find exactly what I need so maybe someone has done this before.在此之前,我已经进行了大量研究,但无法准确找到我需要的东西,所以也许之前有人做过这件事。

Ah-ha!啊哈! You can pass custom functions to the compiler to communicate with the file.您可以将自定义函数传递给编译器以与文件进行通信。

https://sass.github.io/libsass-python/sass.html#custom-functions https://sass.github.io/libsass-python/sass.html#custom-functions

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM