changed main code to handle refactored js parsing API

This commit is contained in:
Pagwin 2025-12-28 20:38:04 -05:00
parent 478fec0000
commit 0f44431086
No known key found for this signature in database
GPG key ID: 81137023740CA260

View file

@ -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
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 $ JS.minify src
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 ()