如何整合Sass和Play 2.3? [英] How to integrate Sass and Play 2.3?

查看:88
本文介绍了如何整合Sass和Play 2.3?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以集成 Sass play-sass 插件,但它不能与Play 2.3一起构建最高为2.2.

解决方案

您可能已经知道,Play已迁移到使用此处.大部分逻辑是用 WebJars 而不是NPM中提取的.

必须修改的过程的两个部分位于JS文件中,该部分用于调用Sass而不是Stylus,而用于解析错误的部分则传递回Play.后者只是编辑parseError函数.前者可以通过直接插入代码来调用Sass来实现,也可以通过将现有的Sass包装器改编为WebJar形式来实现,就像对Stylus所做的那样,并以相同的方式使用它.有在npm上有一对.

编辑我已经使用ShaggyYeti sbt-sass包几个月了,效果非常好.查看其他答案.

Is it possible to integrate Sass and Play Framework 2.3, so that Sass gets compiled to CSS? If so, how should I go about it? I've tried the play-sass plugin, but it doesn't build with Play 2.3, only up to 2.2.

解决方案

As you probably know, Play has migrated to using sbt-web as the model for its asset pipeline, instead of the old system. It's much more flexible than the old system. Unfortunately, since it's so new, it also lacks whole lot of existing packages. You'll either have to write sbt-sass yourself or wait till someone else does. I'm in the same boat for migrating my project to Play 2.3.

From the Play Webinar on Tuesday, Christopher Hunt from Typesafe did a fully fledged example sbt-web plugin for stylus, and linked to the source here. Most of the logic is written Node-style in a JS script, with modules pulled from WebJars instead of NPM.

The two parts of the process that would have to be modified are in the JS file that the part for invoking Sass instead of Stylus and the part for parsing errors to pass back to Play. The latter is just editing the parseError function. The former you could either do by directly plugging in the code to invoke Sass or by adapting an existing Sass wrapper to WebJar form, as they did with Stylus, and using it in the same way. There are a couple on npm that might do the trick.

Edit I've been using the ShaggyYeti sbt-sass package for months now, to great effect. See the other answer.

这篇关于如何整合Sass和Play 2.3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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