on master help sign in
Testing ob run with custom static assets path

TODO: remove assumption of a static module named Static

commita464d2d637d5639d4653c83b5f6c22442ac89585 authorLuigy Leon <luichi.19@gmail.com> dateThu 11 Oct 2018, 13:53 (8 years ago) parent2b3907e
2 files changed+9−3
lib/command/src/Obelisk/Command/Run.hs+1−1 lib/run/src/Obelisk/Run.hs+8−2
lib/command/src/Obelisk/Command/Run.hs+1−1
@@ -51,7 +51,7 @@ run = do
5151 pkgs <- getLocalPkgs
5252 withGhciScript pkgs $ \dotGhciPath -> do
5353 freePort <- getFreePort
54− runGhcid dotGhciPath $ Just $ unwords ["run", show freePort, "Backend.backend", "Frontend.frontend"]
54+ runGhcid dotGhciPath $ Just $ unwords ["run", show freePort, "Static.staticRootPath", "Backend.backend", "Frontend.frontend"]
5555
5656runRepl :: MonadObelisk m => m ()
5757runRepl = do
lib/run/src/Obelisk/Run.hs+8−2
@@ -63,10 +63,11 @@ import Obelisk.Backend
6363
6464run
6565 :: Int -- ^ Port to run the backend
66+ -> FilePath -- ^ Path where the static assets live
6667 -> Backend fullRoute frontendRoute -- ^ Backend
6768 -> Frontend (R frontendRoute) -- ^ Frontend
6869 -> IO ()
69−run port backend frontend = do
70+run port assetsPath backend frontend = do
7071 prettifyOutput
7172 let handleBackendErr (e :: IOException) = hPutStrLn stderr $ "backend stopped; make a change to your code to reload - error " <> show e
7273 --TODO: Use Obelisk.Backend.runBackend; this will require separating the checking and running phases
@@ -79,9 +80,14 @@ run port backend frontend = do
7980 getRouteWith validFullEncoder >>= \case
8081 Identity r -> case r of
8182 InL backendRoute :=> Identity a -> serveRoute $ backendRoute :/ a
82− InR obeliskRoute :=> Identity a -> serveDefaultObeliskApp frontend $ obeliskRoute :/ a
83+ InR obeliskRoute :=> Identity a -> serveDefaultObeliskApp' staticAssets frontend $ obeliskRoute :/ a
8384 let conf = defRunConfig { _runConfig_redirectPort = port }
8485 runWidget conf frontend validFullEncoder `finally` killThread backendTid
86+ where
87+ staticAssets = StaticAssets
88+ { _staticAssets_processed = assetsPath <> ".assets"
89+ , _staticAssets_unprocessed = assetsPath
90+ }
8591
8692getConfigRoute :: IO (Maybe URI)
8793getConfigRoute = get "config/common/route" >>= \case