mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-27 11:05:46 +03:00
Retain staticHttp cache in dev server.
This commit is contained in:
parent
b23c774b68
commit
ebb78e541a
@ -11,6 +11,8 @@ const kleur = require("kleur");
|
||||
const serveStatic = require("serve-static");
|
||||
const connect = require("connect");
|
||||
|
||||
global.staticHttpCache = {};
|
||||
|
||||
const { inject } = require("elm-hot");
|
||||
const serve = serveStatic("static/", { index: false });
|
||||
const serveStaticCode = serveStatic(path.join(__dirname, "../static-code"), {
|
||||
|
@ -40,13 +40,12 @@ function runElmApp(compiledElmPath, pagePath, request) {
|
||||
const route = pagePath.replace(/content\.json\/?$/, "");
|
||||
|
||||
const mode = "elm-to-html-beta";
|
||||
const staticHttpCache = {};
|
||||
const modifiedRequest = { ...request, path: route };
|
||||
const app = requireUncached(compiledElmPath).Elm.TemplateModulesBeta.init({
|
||||
flags: {
|
||||
secrets: process.env,
|
||||
mode,
|
||||
staticHttpCache,
|
||||
staticHttpCache: global.staticHttpCache,
|
||||
request: modifiedRequest,
|
||||
},
|
||||
});
|
||||
@ -68,6 +67,7 @@ function runElmApp(compiledElmPath, pagePath, request) {
|
||||
// generateFiles(fromElm.args[0].filesToGenerate);
|
||||
} else if (fromElm.tag === "PageProgress") {
|
||||
const args = fromElm.args[0];
|
||||
global.staticHttpCache = args.staticHttpCache;
|
||||
|
||||
console.timeEnd(`renderer-${pagePath}`);
|
||||
if (isJson) {
|
||||
|
@ -11,6 +11,7 @@ module Pages.Internal.Platform.Cli exposing
|
||||
import BuildError exposing (BuildError)
|
||||
import Codec
|
||||
import Dict exposing (Dict)
|
||||
import Dict.Extra
|
||||
import ElmHtml.InternalTypes exposing (decodeElmHtml)
|
||||
import ElmHtml.ToString exposing (FormatOptions, defaultFormatOptions, nodeToStringWithOptions)
|
||||
import Head
|
||||
@ -830,7 +831,7 @@ sendSinglePageProgress :
|
||||
-> Model pathKey route
|
||||
-> ( PagePath pathKey, route )
|
||||
-> Effect pathKey
|
||||
sendSinglePageProgress toJsPayload config _ _ =
|
||||
sendSinglePageProgress toJsPayload config _ model =
|
||||
\( page, _ ) ->
|
||||
let
|
||||
makeItWork : StaticHttpRequest.RawRequest staticData -> Result BuildError staticData
|
||||
@ -900,6 +901,7 @@ sendSinglePageProgress toJsPayload config _ _ =
|
||||
, head = success.head
|
||||
, title = viewValue.title
|
||||
, body = "" --lookedUp.unparsedBody
|
||||
, staticHttpCache = model.allRawResponses |> Dict.Extra.filterMap (\k v -> v)
|
||||
}
|
||||
|> sendProgress
|
||||
|
||||
|
@ -33,6 +33,7 @@ type alias ToJsSuccessPayloadNew pathKey =
|
||||
, head : List (Head.Tag pathKey)
|
||||
, body : String
|
||||
, title : String
|
||||
, staticHttpCache : Dict String String
|
||||
}
|
||||
|
||||
|
||||
@ -183,6 +184,9 @@ successCodecNew canonicalSiteUrl currentPagePath =
|
||||
|> Codec.field "head" .head (Codec.list (headCodec canonicalSiteUrl currentPagePath))
|
||||
|> Codec.field "body" .body Codec.string
|
||||
|> Codec.field "title" .title Codec.string
|
||||
|> Codec.field "staticHttpCache"
|
||||
.staticHttpCache
|
||||
(Codec.dict Codec.string)
|
||||
|> Codec.buildObject
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user