Skip to content

Commit 4a25c21

Browse files
committed
Fix: previous commit broke CSS HMR, this one should fix it
1 parent 5b1c39e commit 4a25c21

File tree

5 files changed

+7
-8
lines changed

5 files changed

+7
-8
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,5 +116,5 @@
116116
"lint:scss": "./node_modules/.bin/stylelint **/*.scss --syntax scss",
117117
"test": "npm run lint && npm run jest"
118118
},
119-
"version": "0.4.6"
119+
"version": "0.4.7"
120120
}

src/client/index.jsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,9 @@ export default async function Launch({
5353
const hotSuccess = hotReporter.success;
5454
hotReporter.success = () => {
5555
const stamp = shortId();
56-
const links = document.querySelectorAll('link[rel=stylesheet]');
56+
const links = document.querySelectorAll('link[rel=stylesheet][id="tru-style"]');
5757
for (let i = 0; i < links.length; i += 1) {
58-
const link = links[i];
59-
if (link.href.startsWith('/')) {
60-
link.href = `${link.href.match(/[^?]*/)}?v=${stamp}`;
61-
}
58+
links[i].href = `${links[i].href.match(/[^?]*/)}?v=${stamp}`;
6259
}
6360
hotSuccess();
6461
};

src/server/renderer.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export default function factory(webpackConfig, options) {
137137

138138
if (context.status) res.status(context.status);
139139
const styles = context.chunks.map(chunk => (
140-
`<link data-chunk="${chunk}" href="${publicPath}${chunk}-${timestamp}.css" rel="stylesheet" />`
140+
`<link data-chunk="${chunk}" id="tru-style" href="${publicPath}${chunk}-${timestamp}.css" rel="stylesheet" />`
141141
)).join('');
142142

143143
res.send((
@@ -148,6 +148,7 @@ export default function factory(webpackConfig, options) {
148148
${helmet ? helmet.meta.toString() : ''}
149149
<link
150150
href="${publicPath}main-${timestamp}.css"
151+
id="tru-style"
151152
rel="stylesheet"
152153
/>
153154
${styles}

src/shared/containers/AppChunk/index.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ export default class SplitRoute extends React.Component {
161161
link = document.createElement('link');
162162
link.setAttribute('data-chunk', `${chunkName}`);
163163
link.setAttribute('href', `${PUBLIC_PATH}/${chunkName}-${timestamp}.css`);
164+
link.setAttribute('id', 'tru-style');
164165
link.setAttribute('rel', 'stylesheet');
165166
const head = document.getElementsByTagName('head')[0];
166167
head.appendChild(link);

0 commit comments

Comments
 (0)