Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use process.env.SSR_RESOURCE_DIR replace SSR_RESOURCE_DIR #12370

Merged
merged 2 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/bundler-webpack/src/config/definePlugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ test('normal', () => {
NODE_ENV: '"test"',
PUBLIC_PATH: '"/"',
},
'process.env.SSR_MANIFEST': 'process.env.SSR_MANIFEST',
});
});

Expand All @@ -27,5 +28,6 @@ test('env variables', () => {
UMI_APP_FOO: '"BAR"',
PUBLIC_PATH: '"/"',
},
'process.env.SSR_MANIFEST': 'process.env.SSR_MANIFEST',
});
});
2 changes: 1 addition & 1 deletion packages/bundler-webpack/src/config/definePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function resolveDefine(opts: { define: any; publicPath?: string }) {

return {
'process.env': env,
'process.env.SSR_RESOURCE_DIR': 'process.env.SSR_RESOURCE_DIR',
'process.env.SSR_MANIFEST': 'process.env.SSR_MANIFEST',
...define,
};
}
Expand Down
13 changes: 7 additions & 6 deletions packages/preset-umi/templates/server.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,17 @@ const routesWithServerLoader = {

export function getManifest(sourceDir) {
let manifestPath;
if (process.env.SSR_RESOURCE_DIR) {
manifestPath = path.join(process.env.SSR_RESOURCE_DIR,'build-manifest.json')
} else if (sourceDir) {
if (process.env.SSR_MANIFEST) {
return JSON.parse(process.env.SSR_MANIFEST)
}
if (sourceDir) {
manifestPath = path.join(sourceDir,'build-manifest.json')
}
else {
else {
manifestPath = '{{{ assetsPath }}}'
}
}

return JSON.parse(fs.readFileSync(manifestPath), 'utf-8');
return JSON.parse(fs.readFileSync(manifestPath), 'utf-8');
}

export function createHistory(opts) {
Expand Down
20 changes: 14 additions & 6 deletions packages/renderer-react/src/html.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,13 @@ const HydrateMetadata = (props: IHtmlProps) => {
{htmlPageOpts?.headScripts?.map((script: IScript, key: number) => {
const { content, ...rest } = normalizeScripts(script);
return (
<script key={key} {...(rest as any)}>
{content}
</script>
<script
dangerouslySetInnerHTML={{
__html: content,
}}
key={key}
{...(rest as any)}
/>
);
})}
</>
Expand Down Expand Up @@ -140,9 +144,13 @@ export function Html({
{htmlPageOpts?.scripts?.map((script: IScript, key: number) => {
const { content, ...rest } = normalizeScripts(script);
return (
<script key={key} {...(rest as any)}>
{content}
</script>
<script
dangerouslySetInnerHTML={{
__html: content,
}}
key={key}
{...(rest as any)}
/>
);
})}
</body>
Expand Down
Loading