Skip to content

Commit b426f04

Browse files
authored
fix: do not attempt hot reloading when emit is false (#953)
1 parent 31c165f commit b426f04

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/loader.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ function hotLoader(content, context) {
6969
function pitch(request) {
7070
// @ts-ignore
7171
const options = this.getOptions(/** @type {Schema} */ (schema));
72+
const emit = typeof options.emit !== "undefined" ? options.emit : true;
7273
const callback = this.async();
7374
const optionsFromPlugin = /** @type {TODO} */ (this)[
7475
MiniCssExtractPlugin.pluginSymbol
@@ -114,7 +115,6 @@ function pitch(request) {
114115
}
115116

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

120120
for (const dependency of dependencies) {
@@ -243,9 +243,11 @@ function pitch(request) {
243243

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

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

250252
callback(null, resultSource);
251253
};

0 commit comments

Comments
 (0)