Skip to content

Commit 6ffa72e

Browse files
committed
make id of chunk style link unique
1 parent 50d6622 commit 6ffa72e

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/client/index.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export default async function Launch({
6060
moduleHot.addStatusHandler((status) => {
6161
if (status !== 'ready') return;
6262
const stamp = shortId();
63-
const links = document.querySelectorAll('link[rel=stylesheet][id="tru-style"]');
63+
const links = document.querySelectorAll('link[rel=stylesheet][id^="tru-style"]');
6464
for (let i = 0; i < links.length; i += 1) {
6565
links[i].href = `${links[i].href.match(/[^?]*/)}?v=${stamp}`;
6666
}

src/server/renderer.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ export default function factory(webpackConfig, options) {
177177
assets = assets.filter(asset => asset.endsWith('.css'));
178178
assets.forEach((asset) => {
179179
styles.push((
180-
`<link data-chunk="${chunk}" id="tru-style" href="${publicPath}${asset}" rel="stylesheet" />`
180+
`<link data-chunk="${chunk}" id="tru-style-${chunk.replace('/', '-')}" href="${publicPath}${asset}" rel="stylesheet" />`
181181
));
182182
});
183183
});

src/shared/containers/AppChunk/index.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export default class SplitRoute extends React.Component {
171171
link = document.createElement('link');
172172
link.setAttribute('data-chunk', chunkName);
173173
link.setAttribute('href', `${PUBLIC_PATH}/${chunkName}-${timestamp}.css`);
174-
link.setAttribute('id', 'tru-style');
174+
link.setAttribute('id', `tru-style-${chunkName.replace('/', '-')}`);
175175
link.setAttribute('rel', 'stylesheet');
176176
const head = document.getElementsByTagName('head')[0];
177177
head.appendChild(link);

0 commit comments

Comments
 (0)