简体   繁体   English

在 Visual Studio 的构建定义中包含 SASS 编译器? (并避免在使用 TFS 时合并 CSS 文件)

[英]Include SASS compiler in build definition in Visual Studio? (and avoid merging the CSS files when using TFS)

We plan on using SASS instead of plain CSS for our SharePoint project very soon.我们计划很快在我们的 SharePoint 项目中使用 SASS 而不是纯 CSS。 While testing and trying to set everything up, I ran into some problems:在测试和尝试设置一切时,我遇到了一些问题:

We're using Visual Studio 2015 and on my developer machine I installed the Web Compiler Extension to compile the .scss-files and partial files to a regular .css-file.我们正在使用Visual Studio 2015 ,在我的开发人员机器上,我安装了Web Compiler Extension以将 .scss 文件和部分文件编译为常规的 .css 文件。

That worked very nicely but the problem is, that there will be a few developers working simultaneously on the styles.这工作得很好,但问题是,会有几个开发人员同时在样式上工作。 I want to avoid merging the resulting css-file each time someone tries to check in something into source control (we're using Team Foundation Server ).我想避免每次有人尝试将某些内容签入源代码管理时合并生成的 css 文件(我们正在使用Team Foundation Server )。

Since there is a build running every time someone is checking in their changes, and to deploy the resulting solution to the nightly build machine, the idea was to somehow include the SASS compiler in the build definition.由于每次有人检查他们的更改时都会运行一个构建,并将生成的解决方案部署到每晚构建机器上,所以想法是以某种方式在构建定义中包含 SASS 编译器。 This way the more readable scss-files get merged and the build creates the resulting css-file to include it in the solution.这样,更具可读性的 scss 文件会被合并,并且构建会创建生成的 css 文件以将其包含在解决方案中。 Maybe I'm thinking too complicated, but I just couldn't get that to work so far.也许我想得太复杂了,但到目前为止我无法让它发挥作用。

Any ideas how I can achieve that?有什么想法可以实现吗? (Maybe I should also mention that none of the dev machines got any internet connection) (也许我还应该提一下,所有开发机器都没有任何互联网连接)

If you're building an MVC app, you can use MVC's bundling feature along with the SASS NuGet package .如果您正在构建 MVC 应用程序,则可以将 MVC 的捆绑功能与SASS NuGet 包一起使用。 And, be sure to enable minification.并且,一定要启用缩小。 There's a UseNativeMinification property on SassAndScssSettings .有一个UseNativeMinification物业SassAndScssSettings That way you don't need to deal with merging the css file when you get latest or check in. Reference this thread: SASS/TFS best practice这样,当您获得最新版本或签入时,您无需处理合并 css 文件。参考此线程: SASS/TFS 最佳实践

Another way is running a script (eg with PowerShell task) on the server that to install the gulp components and then call the sass compile task to compile the SASS.另一种方法是在服务器上运行一个脚本(例如使用 PowerShell 任务)来安装 gulp 组件,然后调用 sass 编译任务来编译 SASS。 Refer to Powershell build - compiling SASS for details.有关详细信息,请参阅Powershell 构建 - 编译 SASS

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

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