Powershell构建-编译SASS [英] Powershell build - compiling SASS

查看:56
本文介绍了Powershell构建-编译SASS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在使用Web Workbench的Visual Studio 2010项目中开始使用SASS-但我很难理解通过TFS进行版本控制的问题.为了避免覆盖其他人的更改,我知道应该将输出的CSS从源代码控制中排除,并且应该在构建过程中将SCSS编译到CSS服务器端.当前,我们使用Powershell脚本进行构建,但是我似乎找不到有关如何在Powershell中合并SCSS编译的任何信息.关于此过程是否有任何体面的文件?

I'm hoping to start using SASS in a Visual Studio 2010 project using Web Workbench - but the issue of version control through TFS has me stumped. To avoid overriding someone else's changes I understand that the outputted CSS should be excluded from source control, and that the SCSS should be compiled to CSS server side during the build process. Currently we use a Powershell script for the build, but I can't seem to find any information on how to incorporate SCSS compilation in Powershell. Is there any decent documentation out there on this process?

推荐答案

我认为我通常对Powershell/build脚本缺乏经验,使我对此进行了过度思考.我采取了以下步骤:

I think my lack of experience with Powershell/build scripts in general had me overthinking this. I took the following steps:

1)从此处安装Ruby for Windows: https://www.ruby-lang.org/zh-CN/documentation/installation/

1) Installed Ruby for Windows from here: https://www.ruby-lang.org/en/documentation/installation/

2)打开命令提示符->输入 gem install ruby​​

2) Open Command Prompt -> entered gem install ruby

3)打开PowerGUI脚本编辑器(已安装,但可以在此处下载: http://software.dell.com/products/powergui-freeware/)

3) Opened PowerGUI Script Editor (already installed, but can be downloaded here: http://software.dell.com/products/powergui-freeware/)

4)创建了一个函数来执行以下命令: sass -t压缩的"path \ sassInput.scss""path \ sassOutput.css"

4) Created a function to execute the following: sass -t compressed "path\sassInput.scss" "path\sassOutput.css"

然后再说.我确实想为目录中的每个.scss文件(不是部分文件)执行此操作,但这足以使我立即开始使用.

And presto. I do want to have a way of doing this for each .scss file in the directory that is not a partial, but this is enough to get me started for now.

更新:这就是我为Powershell脚本编写的最终结果:(请注意 $ dirpath 设置为项目的其他位置的根目录)

UPDATE: This is what I ended up with for a Powershell script: (note $dirpath is set to my project's root directory elsewhere)

$stylesheetPath = $dirpath + "App_Themes\"
$files = Get-ChildItem $stylesheetPath -Filter *.scss 
for ($i=0; $i -lt $files.Count; $i++) {
    $file = $files[$i]
    $fileName = $file.BaseName
    $filePath = $file.FullName
    if (-not $fileName.StartsWith("_")) {
        $newFilePath =  "$stylesheetPath$fileName.css"
        sass -t compressed $filePath $newFilePath
    }
}

这篇关于Powershell构建-编译SASS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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