Skip to content

Instantly share code, notes, and snippets.

@KirinDave
Created September 24, 2012 06:34
Show Gist options
  • Save KirinDave/3774612 to your computer and use it in GitHub Desktop.
Save KirinDave/3774612 to your computer and use it in GitHub Desktop.
Rewritten sass helper for hakyll.
{-# LANGUAGE OverloadedStrings, QuasiQuotes #-}
module Helpers.SassCompiler (compressSassCompiler, sassCompiler) where
import qualified Data.ByteString.Char8 as B
import Control.Arrow ((>>>))
import Data.Conduit
import Data.Conduit.Process
import System.Process.QQ
import Data.Conduit.List (consume)
import Hakyll
import Hakyll.Web.CompressCss (compressCss)
compressSassCompiler :: Compiler Resource String
compressSassCompiler = getIdentifier >>> (unsafeCompiler $ compressSassString)
sassCompiler :: Compiler Resource String
sassCompiler = getIdentifier >>> (unsafeCompiler $ compileSassString)
compressSassString :: Identifier a -> IO String
compressSassString = fmap compressCss . compressSassString
compileSassString :: Identifier a -> IO String
compileSassString ident = do
cmdResultList <- runResourceT $ [scmd|sass #{toFilePath ident}|] $$ consume
return $ (B.unpack . head) cmdResultList
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment