Skip to content

Commit 2fe6d1f

Browse files
fix: respect errors and warnings from minimizer without code
1 parent 95e5fa1 commit 2fe6d1f

File tree

5 files changed

+249
-42
lines changed

5 files changed

+249
-42
lines changed

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ class CssMinimizerPlugin {
622622
innerSourceMap,
623623
true,
624624
);
625-
} else {
625+
} else if (item.code) {
626626
output.source = new RawSource(item.code);
627627
}
628628
}
@@ -632,7 +632,7 @@ class CssMinimizerPlugin {
632632
inputSourceMap && CssMinimizerPlugin.isSourceMap(inputSourceMap);
633633

634634
for (const error of result.errors) {
635-
output.warnings.push(
635+
output.errors.push(
636636
CssMinimizerPlugin.buildError(
637637
error,
638638
name,
@@ -691,6 +691,10 @@ class CssMinimizerPlugin {
691691
}
692692
}
693693

694+
if (!output.source) {
695+
return;
696+
}
697+
694698
const newInfo = { minimized: true };
695699
const { source } = output;
696700

src/minify.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ async function minify(options) {
3434
);
3535

3636
if (typeof minifyResult.code !== "string") {
37-
throw new Error(
38-
"minimizer function doesn't return the 'code' property or result is not a string value",
37+
result.errors.push(
38+
new Error(
39+
"minimizer function doesn't return the 'code' property or result is not a string value",
40+
),
3941
);
4042
}
4143

0 commit comments

Comments
 (0)