added a module for bundling
This commit is contained in:
parent
e7dfb662ed
commit
c3637bd12d
3 changed files with 40 additions and 17 deletions
|
|
@ -27,7 +27,7 @@ common warnings
|
||||||
|
|
||||||
library
|
library
|
||||||
hs-source-dirs: src
|
hs-source-dirs: src
|
||||||
exposed-modules: Markdown HTML Logger IR Logger.Shake Psb.Main Utilities Utilities.FilePath Utilities.Action Utilities.Javascript Utilities.CSS Templates Types Config
|
exposed-modules: Markdown HTML Logger IR Logger.Shake Psb.Main Utilities Utilities.FilePath Utilities.Action Utilities.Javascript Utilities.CSS Templates Types Config Utilities.Bundling
|
||||||
other-modules: Utilities.Parsing
|
other-modules: Utilities.Parsing
|
||||||
build-depends: base >=4.20 && < 4.21, mustache >=2.4.2, shake >= 0.19.8, deriving-aeson >= 0.2.9, aeson, text >= 2.1.2, time, unordered-containers, yaml, megaparsec >= 9.7.0, transformers >= 0.6.2, css-syntax >= 0.1.0.2
|
build-depends: base >=4.20 && < 4.21, mustache >=2.4.2, shake >= 0.19.8, deriving-aeson >= 0.2.9, aeson, text >= 2.1.2, time, unordered-containers, yaml, megaparsec >= 9.7.0, transformers >= 0.6.2, css-syntax >= 0.1.0.2
|
||||||
default-extensions: ApplicativeDo DataKinds NamedFieldPuns DerivingVia LambdaCase TypeApplications DeriveGeneric OverloadedRecordDot NamedFieldPuns DuplicateRecordFields DisambiguateRecordFields FlexibleInstances
|
default-extensions: ApplicativeDo DataKinds NamedFieldPuns DerivingVia LambdaCase TypeApplications DeriveGeneric OverloadedRecordDot NamedFieldPuns DuplicateRecordFields DisambiguateRecordFields FlexibleInstances
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ import Text.Megaparsec (errorBundlePretty)
|
||||||
import Text.Mustache (ToMustache (toMustache))
|
import Text.Mustache (ToMustache (toMustache))
|
||||||
import Types
|
import Types
|
||||||
import Utilities.Action (getPublishedPosts, isDraft', markdownToHtml, markdownToPost, now, psbProgress)
|
import Utilities.Action (getPublishedPosts, isDraft', markdownToHtml, markdownToPost, now, psbProgress)
|
||||||
|
import Utilities.Bundling (bundled)
|
||||||
import qualified Utilities.CSS as CSS
|
import qualified Utilities.CSS as CSS
|
||||||
import Utilities.FilePath (indexHtmlOutputPath, indexHtmlSourcePaths, isMarkdownPost, urlConvert)
|
import Utilities.FilePath (indexHtmlOutputPath, indexHtmlSourcePaths, isMarkdownPost, urlConvert)
|
||||||
import qualified Utilities.Javascript as JS
|
import qualified Utilities.Javascript as JS
|
||||||
|
|
@ -73,10 +74,12 @@ buildRules :: Rules ()
|
||||||
buildRules = do
|
buildRules = do
|
||||||
home
|
home
|
||||||
assets
|
assets
|
||||||
|
bundled
|
||||||
postsRule
|
postsRule
|
||||||
rss
|
rss
|
||||||
css_resources
|
|
||||||
js_resources
|
-- css_resources
|
||||||
|
-- js_resources
|
||||||
|
|
||||||
-- make a rule of the pattern outputDir/asset_name which copes from outputDir/../pages
|
-- make a rule of the pattern outputDir/asset_name which copes from outputDir/../pages
|
||||||
assets :: Rules ()
|
assets :: Rules ()
|
||||||
|
|
@ -85,20 +88,20 @@ assets =
|
||||||
let src = FP.dropDirectory1 target
|
let src = FP.dropDirectory1 target
|
||||||
Shake.copyFileChanged src target
|
Shake.copyFileChanged src target
|
||||||
|
|
||||||
css_resources :: Rules ()
|
-- css_resources :: Rules ()
|
||||||
css_resources =
|
-- css_resources =
|
||||||
map (outputDir </>) cssGlobs |%> \target -> do
|
-- map (outputDir </>) cssGlobs |%> \target -> do
|
||||||
src <- Shake.readFile' $ FP.dropDirectory1 target
|
-- src <- Shake.readFile' $ FP.dropDirectory1 target
|
||||||
-- TODO: write to fingerprinted location as well
|
-- -- TODO: write to fingerprinted location as well
|
||||||
Shake.writeFileChanged target $ CSS.minify src
|
-- Shake.writeFileChanged target $ CSS.minify src
|
||||||
|
--
|
||||||
js_resources :: Rules ()
|
-- js_resources :: Rules ()
|
||||||
js_resources =
|
-- js_resources =
|
||||||
map (outputDir </>) jsGlobs |%> \target -> do
|
-- map (outputDir </>) jsGlobs |%> \target -> do
|
||||||
let src_file = FP.dropDirectory1 target
|
-- let src_file = FP.dropDirectory1 target
|
||||||
src <- Shake.readFile' $ src_file
|
-- src <- Shake.readFile' $ src_file
|
||||||
-- TODO: write to fingerprinted location as well
|
-- -- TODO: write to fingerprinted location as well
|
||||||
Shake.writeFileChanged target $ JS.minify src
|
-- Shake.writeFileChanged target $ JS.minify src
|
||||||
|
|
||||||
-- 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
|
-- 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 ()
|
postsRule :: Rules ()
|
||||||
|
|
|
||||||
20
src/Utilities/Bundling.hs
Normal file
20
src/Utilities/Bundling.hs
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
module Utilities.Bundling
|
||||||
|
( bundled,
|
||||||
|
)
|
||||||
|
where
|
||||||
|
|
||||||
|
import Development.Shake (Action, Rules, command_)
|
||||||
|
|
||||||
|
-- does not include specification of output location or input files
|
||||||
|
generic_esbuild_options :: [String]
|
||||||
|
generic_esbuild_options = ["--minify", "--sourcemap", "--bundle", "--chunk-names=[name]-[hash]"]
|
||||||
|
|
||||||
|
-- TODO: not sure if I want all bundling to be an all at once afair, per file format
|
||||||
|
-- or multiple stages for various formats
|
||||||
|
--
|
||||||
|
-- Regardless the objective is to produce all of that while outputting a file to
|
||||||
|
-- indicate completion/fulfill a need directive without rebuilding even when files
|
||||||
|
-- are left unchanged, maybe have the need be a $(filename).hash which we compute
|
||||||
|
-- ourselves based on the unminified input
|
||||||
|
bundled :: Rules ()
|
||||||
|
bundled = error "TODO"
|
||||||
Loading…
Reference in a new issue