Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/loader.js
Original file line number Diff line number Diff line change
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