Skip to content

Instantly share code, notes, and snippets.

@miikka
Created February 20, 2011 14:11
Show Gist options
  • Save miikka/835989 to your computer and use it in GitHub Desktop.
Save miikka/835989 to your computer and use it in GitHub Desktop.
Hakyll + Sass
module Sass (sass) where
import Control.Monad.IO.Class (liftIO)
import Text.Hakyll.File (makeDirectories, toDestination)
import Text.Hakyll.HakyllAction (HakyllAction(..), runHakyllActionIfNeeded)
import Text.Hakyll.HakyllMonad (Hakyll)
import System.FilePath (replaceExtension)
import System.Process (readProcess)
-- | Process a Sass stylesheet into a CSS file. Use like this:
--
-- > main = hakyll "http://example.com/" $ do
-- > sass 'css/base.scss'
sass :: FilePath-> Hakyll ()
sass fp = runHakyllActionIfNeeded sass'
where
url = replaceExtension fp "css"
sass' = HakyllAction
{ actionDependencies = [fp]
, actionUrl = Left $ return url
, actionFunction = \() -> do
destination <- toDestination url
makeDirectories destination
liftIO $ readProcess "sass" [fp, destination] ""
return ()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment