fix: duplicate css (#7137)
CI / build (16.x, ubuntu-latest) (push) Has been cancelled Details
CI / build (16.x, windows-latest) (push) Has been cancelled Details
CI / build (18.x, ubuntu-latest) (push) Has been cancelled Details
CI / build (18.x, windows-latest) (push) Has been cancelled Details
Coverage / coverage (16.x) (push) Has been cancelled Details
Release / Release (16) (push) Has been cancelled Details

* fix: duplicate css

* chore: add changelog

* fix: lint
This commit is contained in:
水澜 2025-09-25 16:44:37 +08:00 committed by GitHub
parent fcc25dc3fd
commit 2742ac4678
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 3 deletions

View File

@ -0,0 +1,5 @@
---
'@ice/runtime': patch
---
fix: duplicate css

View File

@ -1,7 +1,7 @@
import * as React from 'react'; import * as React from 'react';
import type { WindowContext, RouteMatch, AssetsManifest } from './types.js';
import { useAppContext, useAppData } from './AppContext.js'; import { useAppContext, useAppData } from './AppContext.js';
import { getMeta, getTitle, getLinks, getScripts } from './routesConfig.js'; import { getLinks, getMeta, getScripts, getTitle } from './routesConfig.js';
import type { AssetsManifest, RouteMatch, WindowContext } from './types.js';
import getCurrentRoutePath from './utils/getCurrentRoutePath.js'; import getCurrentRoutePath from './utils/getCurrentRoutePath.js';
interface DocumentContext { interface DocumentContext {
@ -81,7 +81,15 @@ export const Links: LinksType = (props: LinksProps) => {
const routeLinks = getLinks(matches, loaderData); const routeLinks = getLinks(matches, loaderData);
const pageAssets = getPageAssets(matches, assetsManifest); const pageAssets = getPageAssets(matches, assetsManifest);
const entryAssets = getEntryAssets(assetsManifest); const entryAssets = getEntryAssets(assetsManifest);
const styles = entryAssets.concat(pageAssets).filter(path => path.indexOf('.css') > -1); let styles = entryAssets.concat(pageAssets).filter(path => path.indexOf('.css') > -1);
// Unique styles for duplicate CSS files.
const cssSet = {};
styles = styles.filter((style) => {
if (cssSet[style]) return false;
cssSet[style] = true;
return true;
});
return ( return (
<> <>