I checked:
|
Failed: async ({ Input }) => |
|
`${red("Error:")} Cannot compress file ${gray( |
|
await Directory(Input), |
|
)}${red((await import("node:path")).parse(Input).base)}`, |
It looks like this is currently not possible, even if I increase Logger level to 3 or higher. Am I right?
For context: I have one particular HTML which is failing compression and I want to find out why. Other HTML files are compressing fine.
Update:
By modifying my local version of this plugin to output more details, I found out that there is a second parameter that you can name as Error:
Failed: async ({ Input }, Error) => { console.error(Error); ... }
It showed me what the actual error is:
Error: Parse Error: <button class="font-display text-[19px] font-semibold .... (a whole bunch of HTML) ...
at HTMLParser.parse (file:///Users/me/project/node_modules/.pnpm/html-minifier-terser@7.2.0/node_modules/html-minifier-terser/src/htmlparser.js:249:15)
at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
at async scan (file:///Users/me/project/node_modules/.pnpm/html-minifier-terser@7.2.0/node_modules/html-minifier-terser/src/htmlminifier.js:810:5)
at async createSortFns (file:///Users/me/project/node_modules/.pnpm/html-minifier-terser@7.2.0/node_modules/html-minifier-terser/src/htmlminifier.js:817:3)
at async minifyHTML (file:///Users/me/project/node_modules/.pnpm/html-minifier-terser@7.2.0/node_modules/html-minifier-terser/src/htmlminifier.js:947:5)
at async Module.minify (file:///Users/me/project/node_modules/.pnpm/html-minifier-terser@7.2.0/node_modules/html-minifier-terser/src/htmlminifier.js:1361:18)
at async Wrote (file:///Users/me/project/node_modules/.pnpm/@playform+compress@0.2.3_@types+node@22.14.1_jiti@2.4.2_rollup@4.40.0_typescript@5.8.3_yaml@2.7.1/node_modules/@playform/compress/Target/Function/Integration.js:1:1476)
at async file:///Users/me/project/node_modules/.pnpm/@playform+pipe@0.1.5/node_modules/@playform/pipe/Target/Function/Pipe.js:1:473
at async Promise.allSettled (index 0)
at async Module.M (file:///Users/me/project/node_modules/.pnpm/@playform+pipe@0.1.5/node_modules/@playform/pipe/Target/Function/Pipe.js:1:834)
Not very clear above what failed parsing, but at least I knew a little better where to look, and I found out there was a syntax error in the Astro file. So I was able to fix it.
I think it's worth outputting the actual error:
Failed: async ({ Input }, Error) => {
Error?.message && console.error(Error.message.slice(0, 100) + "...");
return "Cannot compress file " ...;
}
I checked:
Compress/Source/Variable/Option.ts
Lines 32 to 35 in 3c542a1
It looks like this is currently not possible, even if I increase
Loggerlevel to 3 or higher. Am I right?For context: I have one particular HTML which is failing compression and I want to find out why. Other HTML files are compressing fine.
Update:
By modifying my local version of this plugin to output more details, I found out that there is a second parameter that you can name as
Error:It showed me what the actual error is:
Not very clear above what failed parsing, but at least I knew a little better where to look, and I found out there was a syntax error in the Astro file. So I was able to fix it.
I think it's worth outputting the actual error: