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: do not attempt hotreloading when emit is false #953

Merged
merged 1 commit into from Jun 15, 2022
Merged
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
10 changes: 6 additions & 4 deletions src/loader.js
Expand Up @@ -69,6 +69,7 @@ function hotLoader(content, context) {
function pitch(request) {
// @ts-ignore
const options = this.getOptions(/** @type {Schema} */ (schema));
const emit = typeof options.emit !== "undefined" ? options.emit : true;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hoisted this so we can access it in the hot reloading path

const callback = this.async();
const optionsFromPlugin = /** @type {TODO} */ (this)[
MiniCssExtractPlugin.pluginSymbol
Expand Down Expand Up @@ -114,7 +115,6 @@ function pitch(request) {
}

const identifierCountMap = new Map();
const emit = typeof options.emit !== "undefined" ? options.emit : true;
let lastDep;

for (const dependency of dependencies) {
Expand Down Expand Up @@ -243,9 +243,11 @@ function pitch(request) {

let resultSource = `// extracted by ${MiniCssExtractPlugin.pluginName}`;

resultSource += this.hot
? hotLoader(result, { loaderContext: this, options, locals })
: result;
// only attempt hotreloading if the css is actually used for something other than hash values
resultSource +=
this.hot && emit
? hotLoader(result, { loaderContext: this, options, locals })
: result;

callback(null, resultSource);
};
Expand Down