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

fix: broken hot reloading of global styles #150

Merged
merged 2 commits into from
Mar 11, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "extract-css-chunks-webpack-plugin",
"version": "4.0.0-beta.2",
"version": "0.0.0-development",
"description": "Extract CSS from chunks into stylesheets + HMR. Supports Webpack 4 + SSR",
"license": "MIT",
"author": "James Gillmore <james@faceyspacey.com>",
Expand Down
13 changes: 7 additions & 6 deletions src/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,13 @@ export function pitch(request) {
return callback(e);
}
let resultSource = `// extracted by ${pluginName}`;
if (locals && typeof resultSource !== 'undefined') {
const result = `\nmodule.exports = ${JSON.stringify(locals)};`;
resultSource += query.hot
? hotLoader(result, { context: this.context, query })
: '';
}
const result = locals
? `\nmodule.exports = ${JSON.stringify(locals)};`
: '';

resultSource += query.hot
? hotLoader(result, { context: this.context, query })
: '';

return callback(null, resultSource);
});
Expand Down
2 changes: 1 addition & 1 deletion test/cases/hmr/expected/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
/* 0 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin
// extracted by extract-css-chunks-webpack-plugin

/***/ })
/******/ ]);