Skip to content

Commit

Permalink
fix(next): fix styles hmr
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Feb 26, 2020
1 parent cbeec64 commit 9a015e9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions src/compiler_next/bundle/ext-transforms-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,18 @@ export const extTransformsPlugin = (config: d.Config, compilerCtx: d.CompilerCtx
this.error('Plugin CSS transform error');
}

buildCtx.stylesUpdated.push({
styleTag: pathData.tag,
styleMode: pathData.mode,
styleText: cssTransformResults.styleText,
const hasUpdatedStyle = buildCtx.stylesUpdated.some(s => {
return s.styleTag === pathData.tag && s.styleMode === pathData.mode && s.styleText === cssTransformResults.styleText
});

if (!hasUpdatedStyle) {
buildCtx.stylesUpdated.push({
styleTag: pathData.tag,
styleMode: pathData.mode,
styleText: cssTransformResults.styleText,
});
}

return {
code: cssTransformResults.code,
map: cssTransformResults.map,
Expand Down
2 changes: 1 addition & 1 deletion src/dev-server/hmr-client/hmr-inline-styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const hmrInlineStyles = (elm: Element, versionId: string, stylesUpdated:
};

const hmrStyleElement = (elm: Element, versionId: string, stylesUpdated: d.HmrStyleUpdate) => {
const styleId = elm.getAttribute('s-id');
const styleId = elm.getAttribute('sty-id');
if (styleId === stylesUpdated.styleId && stylesUpdated.styleText) {
// if we made it this far then it's a match!
// update the new style text
Expand Down

0 comments on commit 9a015e9

Please sign in to comment.