Created
April 7, 2014 08:36
-
-
Save ndmitchell/10016729 to your computer and use it in GitHub Desktop.
Shake .min.js build system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DeriveDataTypeable, GeneralizedNewtypeDeriving #-} | |
module Temp where | |
import Development.Shake | |
import Development.Shake.Classes | |
import Development.Shake.FilePath | |
import Data.Char | |
newtype JsFiles = JsFiles () deriving (Show,Typeable,Eq,Hashable,Binary,NFData) | |
main = shakeArgs shakeOptions $ do | |
want ["tester/bundle.jsz"] | |
"//*.min.js" *> \out -> do | |
putNormal "Running minimizer" | |
let src = dropExtension out -<.> "js" | |
writeFile' out . filter (not . isSpace) =<< readFile' src | |
jsFiles <- addOracle $ \(JsFiles _) -> | |
fmap (filter $ \x -> takeExtensions x == ".js") $ getDirectoryFiles "" ["tester//*.js"] | |
"//*.jsz" *> \out -> do | |
putNormal "Running compressor" | |
js <- jsFiles $ JsFiles () | |
let mjs = map (-<.> "min.js") js | |
need mjs | |
writeFile' out . unlines =<< mapM readFile' mjs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment