minier
v2.0.1
Published
Automatic Batch Code Compressor
Downloads
34
Maintainers
Readme
minier
Automatic Batch Code Compressor.
❓ What
Automatically and batch compresses code files in a directory while preserving the original file tree.
- ✨ Zero configuration available.
- 🎉 Supports .html / .htm / .css / .js / .mjs / .cjs / .json / .xml / .svg files.
- 📦 Extremely fast compression speed.
🎈 Installation
npm install -D minier@latestOr use a global installation, which will get the input/output directories for the minier.config.json and relative paths from the directory where the minier command was run.
npm install -g minier@latestBuild commands
minier build✨ Use ESM
import minier from "minier";
minier({
baseDir: "src/",
outDir: "release/"
/* ... */
});📝 Configuration
When baseDir and outDir are the same, minier will create a temporary directory as outDir, and the temporary directory will be deleted immediately after the mission is completed, and the files in the baseDir will be overwritten.
Whether in minier.config.json or in the way ESM is used, their configuration items are consistent.
outDir
Specify the output directory. It can also be specified from the -o or --output of the CLI.
String config.outDir || "release/"
{
"outDir": "example-output-folder/"
}baseDir
Specify the input directory from which the files that need to be processed before compression will be read. It can also be specified from the -i or --input of the CLI.
String config.baseDir || "src/"
{
"baseDir": "example-input-folder/"
}ignore
Based on baseDir ignores directories or files, does not count towards the total number of files, and is copied directly to the output directory.
Array config.ignore || []
{
"ignore": [
"node_modules/**",
"dir/**",
"sub/dir/**",
"**/*.mjs"
]
}cleanOutDir
Clear the output folder before exporting.
Boolean config.cleanOutDir || false
{
"cleanOutDir": true
}html.minifyCSS
Compress the <style> tag at the same time.
Boolean config.html.minifyCSS || true
{
"html": {
"minifyCSS": false
}
}html.minifyJS
Compress the <script> tag at the same time.
Boolean config.html.minifyJS || true
{
"html": {
"minifyJS": false
}
}js.noSpaces
Remove two consecutive spaces in JavaScript.
Boolean config.js.noSpaces || false
Relatively aggressive configuration items.
{
js: {
noSpaces: true
}
}🎉 Configure inheritance
esbuild
This affects .js, .mjs, .cjs, .css files and <script>, <style> tags.
If sourcemap is truthy, it will always be inline.
{
js: {
esbuild: {
loader: "js",
minify: true
}
},
css: {
esbuild: {
loader: "css",
minify: true
}
}
}htmlTerser
This affects .html and .htm files.
{
htmlTerser: {
caseSensitive: true,
collapseBooleanAttributes: true,
collapseWhitespace: true,
conservativeCollapse: false,
decodeEntities: false,
html5: true,
removeComments: true,
removeEmptyAttributes: true,
removeScriptTypeAttributes: false,
removeStyleLinkTypeAttributes: false,
keepClosingSlash: true,
...config.htmlTerser
}
}xmlMinify
This affects .svg and .xml files.
{
xmlMinify: {
removeComments: true,
removeWhitespaceBetweenTags: true,
...config.xmlMinify
}
}📜 License
MIT © ZeoSeven
📑 Changelog
The changelog is included in the package as /changelog.md.
