Skip to content

Commit

Permalink
fix: do not attempt hot reloading when emit is false (#953)
Browse files Browse the repository at this point in the history
  • Loading branch information
ntucker committed Jun 15, 2022
1 parent 31c165f commit b426f04
Showing 1 changed file with 6 additions and 4 deletions.
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;
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

0 comments on commit b426f04

Please sign in to comment.