play sass not working

2019-09-09 02:59发布

问题:

I have followed the instructions on https://github.com/jlitola/play-sass. My plugins.sbt reads (for the last two lines)

resolvers += "Sonatype OSS Releases" at "https://oss.sonatype.org/content/repositories/releases"

addSbtPlugin("net.litola" % "play-sass" % "0.3.0")`

For build.sbt, I earlier had SassPlugin.sassSettings on the last line (separate from playScalaSettings). I've changed it now to

net.litola.SassPlugin.sassSettings + play.Project.playScalaSettings

However, I still can't get this to work :-). My files are in

app/assets/first.scss

app/assets/stylesheets/second.scss

app/assets/styles/third.scss

app/assets/style/fourth.scss

(EDIT: delibrerately different so that I know which one works), however, I don't see any resulting css. scss and sass work fine from command line.

Looks like changes in plugins.sbt and build.sbt are recognized by play because when I intentionally add a typo, SassPlugin.sassSetting in place of SassPlugin.sassSettings, play reload update gives me an error which fixes when I fix the typo back. Would someone know what I'm doing wrong?

EDIT: I'm on play2.2 btw.

回答1:

Hello A couple of observations.

1) Structure: Keep your sass files in the following structure

app/assets/stylesheets/first.scsc
app/assets/stylesheets/second.scsc
app/assets/stylesheets/third.scsc
app/assets/stylesheets/forth.scsc

2) build.sbt keep the code on separate lines with at least once line space in between as shown bellow.

play.Project.playScalaSettings

net.litola.SassPlugin.sassSettings

3) plugins.sbt is fine.