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,15 +45,22 @@ 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" ] { ebHaskellName = Just $ pathToName sassLoc
= return . pure $ def , ebLocation
{ ebHaskellName = Just $ pathToName sassLoc , ebMimeType = "text/css"
, ebLocation , ebProductionContent = either (fail <=< Sass.errorMessage) (return . LBS.fromStrict) =<< Sass.compileFile fp def
, ebMimeType = "text/css" , ebDevelReload = [| either (fail <=< Sass.errorMessage) (return . LBS.fromStrict) =<< Sass.compileFile $(litE $ stringL fp) def |]
, ebProductionContent = either (fail <=< Sass.errorMessage) (return . LBS.fromStrict) =<< Sass.compileFile fp def }
, ebDevelReload = [| either (fail <=< Sass.errorMessage) (return . LBS.fromStrict) =<< Sass.compileFile $(litE $ stringL fp) def |] where
} 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 where
ebLocation = sassLoc -<.> "css" ebLocation = sassLoc -<.> "css"
compile ebMimeType ebLocation fp = return . pure $ def compile ebMimeType ebLocation fp = return . pure $ def