Handle sass properly (as opposed to scss)

This commit is contained in:
Gregor Kleen 2019-02-13 19:58:35 +01:00
parent ec3ec2a882
commit fb52b2024b

View File

@ -19,6 +19,7 @@ import qualified Data.ByteString.Lazy as LBS
import qualified Data.Map as Map import qualified Data.Map as Map
import qualified Text.Sass.Compilation as Sass import qualified Text.Sass.Compilation as Sass
import Text.Sass.Options
import Data.Default import Data.Default
@ -44,9 +45,7 @@ compile :: MimeType
-> Location -- ^ Relative location -> Location -- ^ Relative location
-> FilePath -- ^ Absolute filepath -> FilePath -- ^ Absolute filepath
-> IO [Entry] -> IO [Entry]
compile sassMime sassLoc fp compile "text/x-scss" sassLoc fp = return . pure $ def
| sassMime `elem` [ "text/x-sass", "text/x-scss" ]
= return . pure $ def
{ ebHaskellName = Just $ pathToName sassLoc { ebHaskellName = Just $ pathToName sassLoc
, ebLocation , ebLocation
, ebMimeType = "text/css" , ebMimeType = "text/css"
@ -55,6 +54,15 @@ compile sassMime sassLoc fp
} }
where where
ebLocation = sassLoc -<.> "css" ebLocation = sassLoc -<.> "css"
compile "text/x-sass" sassLoc fp = return . pure $ def
{ ebHaskellName = Just $ pathToName sassLoc
, ebLocation
, ebMimeType = "text/css"
, ebProductionContent = either (fail <=< Sass.errorMessage) (return . LBS.fromStrict) =<< Sass.compileFile fp (def { sassIsIndentedSyntax = True })
, ebDevelReload = [| either (fail <=< Sass.errorMessage) (return . LBS.fromStrict) =<< Sass.compileFile $(litE $ stringL fp) (def { sassIsIndentedSyntax = True }) |]
}
where
ebLocation = sassLoc -<.> "css"
compile ebMimeType ebLocation fp = return . pure $ def compile ebMimeType ebLocation fp = return . pure $ def
{ ebHaskellName = Just $ pathToName ebLocation { ebHaskellName = Just $ pathToName ebLocation
, ebLocation , ebLocation