Skip to content

Commit

Permalink
Some "fixes"
Browse files Browse the repository at this point in the history
  • Loading branch information
KTibow committed Oct 12, 2023
1 parent e212e97 commit d818085
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions build-scripts/lightningcss.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,20 @@ module.exports.getMinifyCSS = ({ latestBuild, isProdBuild }) => {
return (text, type) => {
if (!text) return text;
const input = wrapCSS(text, type);
const { styles: ccss, errors, warnings: w1 } = cleanCSS.minify(input);
if (errors.length > 0) {
console.error("[CCSS] Errors while transforming CSS:", ...errors);
}
if (w1.length > 0) {
console.warn("[CCSS] Warnings while transforming CSS:", ...w1);
}
if (text.includes("babel-plugin-template-html-minifier")) {
const output = unwrapCSS(ccss, type);
return output;
const { styles: ccss, errors, warnings: w1 } = cleanCSS.minify(input);
if (errors.length > 0) {
console.error("[CCSS] Errors while transforming CSS:", ...errors);
}
if (w1.length > 0) {
console.warn("[CCSS] Warnings while transforming CSS:", ...w1);
}
try {
return unwrapCSS(ccss, type);
} catch (e) {
console.error("[CCSS] Invalid output", { text, type, output: ccss });
return text;
}
}
const { code, warnings: w2 } = lightningcss.transform({
filename: "style.css",
Expand All @@ -49,7 +53,11 @@ module.exports.getMinifyCSS = ({ latestBuild, isProdBuild }) => {
console.warn("[LCSS] Warnings while transforming CSS:", ...w2);
}
const lcss = decoder.decode(code);
const output = unwrapCSS(lcss, type);
return output;
try {
return unwrapCSS(lcss, type);
} catch (e) {
console.error("[LCSS] Invalid output", { text, type, output: lcss });
return text;
}
};
};

0 comments on commit d818085

Please sign in to comment.