web: fix static file embedding in non-dev builds
This commit is contained in:
		
							parent
							
								
									8c7eea9ee0
								
							
						
					
					
						commit
						0c73d91f94
					
				| @ -55,12 +55,3 @@ getApplicationDev = | |||||||
|     loader = loadConfig (configSettings Development) |     loader = loadConfig (configSettings Development) | ||||||
|         { csParseExtra = parseExtra |         { csParseExtra = parseExtra | ||||||
|         } |         } | ||||||
| 
 |  | ||||||
| -- #ifdef PRODUCTION |  | ||||||
| --     putStrLn $ "Production mode, using embedded web files" |  | ||||||
| --     let s = $(embed staticDir) |  | ||||||
| -- #else |  | ||||||
| --     putStrLn $ "Not in production mode, using web files from " ++ staticDir ++ "/" |  | ||||||
| --     s <- staticDevel staticDir |  | ||||||
| -- #endif |  | ||||||
| 
 |  | ||||||
|  | |||||||
| @ -12,20 +12,25 @@ This is a separate module to satisfy template haskell requirements. | |||||||
| module Hledger.Web.Settings.StaticFiles where | module Hledger.Web.Settings.StaticFiles where | ||||||
| 
 | 
 | ||||||
| import Prelude (IO) | import Prelude (IO) | ||||||
|  | import System.IO | ||||||
| import Yesod.Static | import Yesod.Static | ||||||
| import qualified Yesod.Static as Static | import qualified Yesod.Static as Static | ||||||
| 
 | 
 | ||||||
|  | import Prelude | ||||||
| import Hledger.Web.Settings (staticDir) | import Hledger.Web.Settings (staticDir) | ||||||
| 
 | 
 | ||||||
| -- | use this to create your static file serving site | -- | use this to create your static file serving site | ||||||
| staticSite :: IO Static.Static | staticSite :: IO Static.Static | ||||||
| staticSite = | staticSite = do | ||||||
| #ifdef DEVELOPMENT | #ifdef DEVELOPMENT | ||||||
|  |   putStrLn ("using web files from: " ++ staticDir ++ "/") >> hFlush stdout | ||||||
|   Static.staticDevel staticDir |   Static.staticDevel staticDir | ||||||
| #else | #else | ||||||
|   Static.static staticDir |   putStrLn "using embedded web files" >> hFlush stdout | ||||||
|  |   return $(Static.embed staticDir) | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| -- | This generates easy references to files in the static directory at compile time, | -- | This generates easy references to files in the static directory at compile time, | ||||||
| --   giving you compile-time verification that referenced files exist. | --   giving you compile-time verification that referenced files exist. | ||||||
| --   Warning: any files added to your static directory during run-time can't be | --   Warning: any files added to your static directory during run-time can't be | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user