diff --git a/src/Psb/Main.hs b/src/Psb/Main.hs index b62f719..2ae2e21 100644 --- a/src/Psb/Main.hs +++ b/src/Psb/Main.hs @@ -21,6 +21,7 @@ import qualified Development.Shake as Shake import Development.Shake.FilePath (()) import qualified Development.Shake.FilePath as FP import Templates +import Text.Megaparsec (errorBundlePretty) import Types import Utilities.Action (getPublishedPosts, isDraft', markdownToHtml, markdownToPost, now, psbProgress) import qualified Utilities.CSS as CSS @@ -92,9 +93,15 @@ css_resources = js_resources :: Rules () js_resources = map (outputDir ) jsGlobs |%> \target -> do - src <- Shake.readFile' $ FP.dropDirectory1 target - -- TODO: write to fingerprinted location as well - Shake.writeFileChanged target $ JS.minify src + let src_file = FP.dropDirectory1 target + src <- Shake.readFile' $ src_file + + let tokenization = JS.toTokens src_file src + case tokenization of + Left e -> error $ "Attempt to tokenize javascript file failed with: " <> errorBundlePretty e + Right tokens -> + -- TODO: write to fingerprinted location as well + Shake.writeFileChanged target $ foldMap JS.displayToken $ JS.minify $ tokens -- there's probably a better way of doing this that allows for the target's origin file extension to get passed in but for now we're doing brute force postsRule :: Rules ()