Skip to content

Commit

Permalink
Combine CSS/JS yesodweb/yesod#517
Browse files Browse the repository at this point in the history
  • Loading branch information
snoyberg committed Apr 21, 2013
1 parent 95a04a7 commit fe2e2a0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Foundation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ instance Yesod App where
-- you to use normal widget features in default-layout.

pc <- widgetToPageContent $ do
$(widgetFile "normalize")
addStylesheet $ StaticR css_bootstrap_css
$(combineStylesheets 'StaticR
[ css_normalize_css
, css_bootstrap_css
])
$(widgetFile "default-layout")
hamletToRepHtml $(hamletFile "templates/default-layout-wrapper.hamlet")

Expand Down
16 changes: 16 additions & 0 deletions Settings/StaticFiles.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import Yesod.Static
import qualified Yesod.Static as Static
import Settings (staticDir)
import Settings.Development
import Language.Haskell.TH (Q, Exp, Name)
import Data.Default (def)

-- | use this to create your static file serving site
staticSite :: IO Static.Static
Expand All @@ -16,3 +18,17 @@ staticSite = if development then Static.staticDevel staticDir
-- Warning: any files added to your static directory during run-time can't be
-- accessed this way. You'll have to use their FilePath or URL to access them.
$(staticFiles Settings.staticDir)

combineSettings :: CombineSettings
combineSettings = def

-- The following two functions can be used to combine multiple CSS or JS files
-- at compile time to decrease bandwidth usage. Sample usage (inside a Widget):
--
-- $(combineStylesheets 'StaticR [style1_css, style2_css])

combineStylesheets :: Name -> [Route Static] -> Q Exp
combineStylesheets = combineStylesheets' development combineSettings

combineScripts :: Name -> [Route Static] -> Q Exp
combineScripts = combineScripts' development combineSettings
File renamed without changes.

0 comments on commit fe2e2a0

Please sign in to comment.