html-minifier-next 6.2.10 → 6.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +21 -3
- package/package.json +2 -2
package/cli.js
CHANGED
|
@@ -58,7 +58,8 @@ import { optionDefinitions } from './src/lib/option-definitions.js';
|
|
|
58
58
|
const require = createRequire(import.meta.url);
|
|
59
59
|
const pkg = require('./package.json');
|
|
60
60
|
|
|
61
|
-
const
|
|
61
|
+
const EXTENSIONS_DEFAULT = ['html', 'htm', 'shtml', 'shtm'];
|
|
62
|
+
const EXTENSIONS_NON_HTML = new Set(['css', 'js', 'mjs', 'cjs', 'jsx', 'ts', 'tsx', 'svg']);
|
|
62
63
|
|
|
63
64
|
const MARK_ERROR = process.stderr.isTTY ? '\x1b[31m' : '';
|
|
64
65
|
const MARK_SUCCESS = process.stderr.isTTY ? '\x1b[32m' : '';
|
|
@@ -362,7 +363,7 @@ program.helpOption('-h, --help', 'Display help for command');
|
|
|
362
363
|
programOptions.preset = 'comprehensive';
|
|
363
364
|
|
|
364
365
|
const inputDirResolved = await fs.promises.realpath(cwd).catch(() => cwd);
|
|
365
|
-
const extensions =
|
|
366
|
+
const extensions = EXTENSIONS_DEFAULT;
|
|
366
367
|
const ignorePatterns = ['node_modules'];
|
|
367
368
|
|
|
368
369
|
const showProgress = process.stderr.isTTY;
|
|
@@ -732,7 +733,7 @@ program.helpOption('-h, --help', 'Display help for command');
|
|
|
732
733
|
|
|
733
734
|
// Resolve file extensions: CLI argument > config file > defaults
|
|
734
735
|
const hasCliFileExt = program.getOptionValueSource('fileExt') === 'cli';
|
|
735
|
-
const resolvedFileExt = hasCliFileExt ? (fileExt || '*') : (config.fileExt ||
|
|
736
|
+
const resolvedFileExt = hasCliFileExt ? (fileExt || '*') : (config.fileExt || EXTENSIONS_DEFAULT);
|
|
736
737
|
|
|
737
738
|
// Resolve ignore patterns: CLI argument takes priority over config file
|
|
738
739
|
const hasCliIgnoreDir = program.getOptionValueSource('ignoreDir') === 'cli';
|
|
@@ -745,6 +746,16 @@ program.helpOption('-h, --help', 'Display help for command');
|
|
|
745
746
|
fatal('You need to specify where to write the output files with the option `--output-dir`');
|
|
746
747
|
}
|
|
747
748
|
|
|
749
|
+
{
|
|
750
|
+
const extList = Array.isArray(resolvedFileExt) ? resolvedFileExt : parseFileExtensions(String(resolvedFileExt || ''));
|
|
751
|
+
const isWildcard = extList.includes('*');
|
|
752
|
+
const nonHtmlExts = isWildcard ? [] : extList.filter(e => EXTENSIONS_NON_HTML.has(e));
|
|
753
|
+
if (isWildcard || nonHtmlExts.length > 0) {
|
|
754
|
+
const label = isWildcard ? 'all file types' : nonHtmlExts.map(e => `.${e}`).join(', ');
|
|
755
|
+
console.error(`${MARK_WARNING}Warning: Processing ${label}—HTML Minifier Next processes CSS, JavaScript, and SVG only when embedded in HTML. Non-HTML files may produce incomplete or broken output.${MARK_RESET}`);
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
|
|
748
759
|
await (async () => {
|
|
749
760
|
// `--dry` automatically enables verbose mode
|
|
750
761
|
const isVerbose = programOptions.verbose || programOptions.dry;
|
|
@@ -840,6 +851,13 @@ program.helpOption('-h, --help', 'Display help for command');
|
|
|
840
851
|
getActiveOptionsDisplay(minifierOptions);
|
|
841
852
|
}
|
|
842
853
|
|
|
854
|
+
for (const file of capturedFiles) {
|
|
855
|
+
const ext = path.extname(file).replace(/^\./, '').toLowerCase();
|
|
856
|
+
if (EXTENSIONS_NON_HTML.has(ext)) {
|
|
857
|
+
console.error(`${MARK_WARNING}Warning: “${path.basename(file)}” does not appear to be an HTML file—HTML Minifier Next processes CSS, JavaScript, and SVG only when embedded in HTML. The output may be incomplete or broken.${MARK_RESET}`);
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
|
|
843
861
|
const concurrency = Math.max(1, Math.min(os.cpus().length || 4, 8));
|
|
844
862
|
const inputs = capturedFiles.slice();
|
|
845
863
|
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@commitlint/cli": "^21.0.1",
|
|
18
18
|
"@eslint/js": "^10.0.1",
|
|
19
|
-
"@rollup/plugin-commonjs": "^29.0.
|
|
19
|
+
"@rollup/plugin-commonjs": "^29.0.3",
|
|
20
20
|
"@rollup/plugin-json": "^6.1.0",
|
|
21
21
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
22
22
|
"@swc/core": "^1.15.40",
|
|
@@ -98,5 +98,5 @@
|
|
|
98
98
|
},
|
|
99
99
|
"type": "module",
|
|
100
100
|
"types": "./dist/types/htmlminifier.d.ts",
|
|
101
|
-
"version": "6.2.
|
|
101
|
+
"version": "6.2.11"
|
|
102
102
|
}
|