html-minifier-next 6.2.9 → 6.2.10
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/README.md +3 -2
- package/cli.js +9 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -34,7 +34,8 @@ Use `npx html-minifier-next --help` to check all available options:
|
|
|
34
34
|
| `--input-dir <dir>`, `-I <dir>` | Specify an input directory | `--input-dir=src` |
|
|
35
35
|
| `--ignore-dir <patterns>`, `-X <patterns>` | Exclude directories—relative to input directory—from processing (comma-separated, overrides config file setting) | `--ignore-dir=libs`, `--ignore-dir=libs,vendor,node_modules` |
|
|
36
36
|
| `--output-dir <dir>`, `-O <dir>` | Specify an output directory | `--output-dir=dist` |
|
|
37
|
-
| `--
|
|
37
|
+
| `--input <file>`, `-i <file>` | Specify input file (alternative to positional argument; pair with `--output` for file output) | `npx html-minifier-next -i input.html -o output.html` |
|
|
38
|
+
| `--output <file>`, `-o <file>` | Specify output file (reads from `--input` file argument or STDIN; outputs to STDOUT if not specified) | File to file: `npx html-minifier-next input.html -o output.html`<br>File to file (explicit): `npx html-minifier-next -i input.html -o output.html`<br>Pipe to file: `cat input.html \| npx html-minifier-next -o output.html`<br>File to STDOUT: `npx html-minifier-next input.html` |
|
|
38
39
|
| `--file-ext <extensions>`, `-f <extensions>` | Specify file extension(s) to process (comma-separated, overrides config file setting); defaults to `html,htm,shtml,shtm`; use `*` for all files | `--file-ext=html,php`, `--file-ext='*'` |
|
|
39
40
|
| `--preset <name>`, `-p <name>` | Use a preset configuration (conservative or comprehensive) | `--preset=conservative` |
|
|
40
41
|
| `--config-file <file>`, `-c <file>` | Use a configuration file | `--config-file=html-minifier.json` |
|
|
@@ -179,7 +180,7 @@ Options can be used in config files (camelCase) or via CLI flags (kebab-case wit
|
|
|
179
180
|
|
|
180
181
|
### Sorting attributes and style classes
|
|
181
182
|
|
|
182
|
-
Minifier options like `sortAttributes` and `sortClassNames` won’t impact the plain
|
|
183
|
+
Minifier options like `sortAttributes` and `sortClassNames` won’t impact the plain-text size of the output. However, using these options for more consistent ordering improves the compression ratio for Gzip and Brotli used over HTTP.
|
|
183
184
|
|
|
184
185
|
### CSS minification
|
|
185
186
|
|
package/cli.js
CHANGED
|
@@ -171,7 +171,8 @@ mainOptionKeys.forEach(function (key) {
|
|
|
171
171
|
program.option(cliFlag, description, parser);
|
|
172
172
|
}
|
|
173
173
|
});
|
|
174
|
-
program.option('-
|
|
174
|
+
program.option('-i --input <file>', 'Specify input file (alternative to positional argument; pair with `--output` for output)');
|
|
175
|
+
program.option('-o --output <file>', 'Specify output file (reads from `--input` file argument or STDIN; outputs to STDOUT if not specified)');
|
|
175
176
|
program.option('-v --verbose', 'Show detailed processing information');
|
|
176
177
|
program.option('-d --dry', 'Dry run: Process and report statistics without writing output');
|
|
177
178
|
program.addHelpText('after', '\nBoolean options support a `--no-<flag>` form to disable them, overriding a preset or config file (e.g., `--preset=comprehensive --no-collapse-whitespace`).');
|
|
@@ -318,7 +319,11 @@ program.helpOption('-h, --help', 'Display help for command');
|
|
|
318
319
|
}
|
|
319
320
|
}
|
|
320
321
|
|
|
321
|
-
//
|
|
322
|
+
// If `--input` was specified, treat it as a positional file argument
|
|
323
|
+
if (programOptions.input) {
|
|
324
|
+
capturedFiles.unshift(programOptions.input);
|
|
325
|
+
filesProvided = true;
|
|
326
|
+
}
|
|
322
327
|
|
|
323
328
|
// Handle zero config mode (standalone in-place minification of the current folder)
|
|
324
329
|
if (programOptions.zero) {
|
|
@@ -735,7 +740,7 @@ program.helpOption('-h, --help', 'Display help for command');
|
|
|
735
740
|
|
|
736
741
|
if (inputDir || outputDir) {
|
|
737
742
|
if (!inputDir) {
|
|
738
|
-
fatal('The option `output-dir` needs to be used with the option `input-dir`—if you are working with a single file, use
|
|
743
|
+
fatal('The option `output-dir` needs to be used with the option `input-dir`—if you are working with a single file, use `--input`/`--output`');
|
|
739
744
|
} else if (!outputDir) {
|
|
740
745
|
fatal('You need to specify where to write the output files with the option `--output-dir`');
|
|
741
746
|
}
|
|
@@ -780,7 +785,7 @@ program.helpOption('-h, --help', 'Display help for command');
|
|
|
780
785
|
try {
|
|
781
786
|
const stat = await fs.promises.stat(inputDir);
|
|
782
787
|
if (!stat.isDirectory()) {
|
|
783
|
-
fatal(inputDir
|
|
788
|
+
fatal(`${inputDir} is not a directory—to minify a single file, use \`--input\`/\`--output\`: html-minifier-next [options] -i ${inputDir} -o <output-file>`);
|
|
784
789
|
}
|
|
785
790
|
} catch (err) {
|
|
786
791
|
fatal('Cannot read directory ' + inputDir + '\n' + err.message);
|
package/package.json
CHANGED