Skip to content

Commit

Permalink
do not add prod scripts in dev (solidjs#1031)
Browse files Browse the repository at this point in the history
Co-authored-by: Ryan Carniato <ryansolid@gmail.com>
  • Loading branch information
edivados and ryansolid authored Aug 30, 2023
1 parent 81ab04b commit f351f42
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions packages/start/root/Scripts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useRequest } from "../server/ServerContext";
import { InlineStyles } from "./InlineStyles";

const isDev = import.meta.env.MODE === "development";
const isProd = import.meta.env.PROD;
const isSSR = import.meta.env.START_SSR;
const isIslands = import.meta.env.START_ISLANDS;

Expand Down Expand Up @@ -44,22 +45,24 @@ function DevScripts() {
function ProdScripts() {
const context = useRequest();
return (
<>
{isSSR && <HydrationScript />}
<NoHydration>
<IslandsScript />
{isServer &&
(isSSR ? (
<script type="module" async src={context!.env.manifest?.["entry-client"].script.href} />
) : import.meta.env.START_INDEX_HTML ? (
// used in the SPA build index.html mode to create a reference to index html
// which will be used by the client build
<script type="module" async src={import.meta.env.START_ENTRY_CLIENT} $ServerOnly />
) : (
<script type="module" async src={context!.env.manifest?.["index.html"].script.href} />
))}
</NoHydration>
</>
isProd && (
<>
{isSSR && <HydrationScript />}
<NoHydration>
<IslandsScript />
{isServer &&
(isSSR ? (
<script type="module" async src={context!.env.manifest?.["entry-client"].script.href} />
) : import.meta.env.START_INDEX_HTML ? (
// used in the SPA build index.html mode to create a reference to index html
// which will be used by the client build
<script type="module" async src={import.meta.env.START_ENTRY_CLIENT} $ServerOnly />
) : (
<script type="module" async src={context!.env.manifest?.["index.html"].script.href} />
))}
</NoHydration>
</>
)
);
}

Expand Down

0 comments on commit f351f42

Please sign in to comment.