@zilero/gulp-html-squeezer
v1.0.4
Published
A Gulp plugin for advanced HTML minification and optimization with Terser, supporting custom compression rules
Downloads
14
Readme
📄 Powerful Gulp plugin for HTML minification using html-minifier-terser.
Installation • Options • Example
✨ Features
- 📦 HTML minification and optimization
- 🔧 Highly configurable
- 📝 TypeScript support
- 🚀 Stream-based processing
- 💡 Progress logging
- 🛠️ Pre and post processing hooks
🚀 Installation
npm install @zilero/gulp-html-squeezer --save-dev
# or
yarn add @zilero/gulp-html-squeezer --dev
# or
pnpm add @zilero/gulp-html-squeezer --save-dev⚙️ Options
htmlMinifierOptions
- Type:
Options(from html-minifier-terser) - Required:
false - HTML minification options
pluginOptions
- Type:
object - Required:
false
pluginOptions.onBeforeMinify
- Type:
(content: string) => Promise<string> | string - Required:
false - Transform content before minification
pluginOptions.onAfterMinify
- Type:
(content: string) => Promise<string> | string - Required:
false - Transform content after minification
📝 Example
gulp.task('advanced-minify', () => {
return gulp.src('src/**/*.html')
.pipe(GulpHtmlSqueezer({
htmlMinifierOptions: {
collapseWhitespace: true,
removeComments: true,
minifyCSS: true,
minifyJS: true,
removeEmptyAttributes: true
},
pluginOptions: {
onBeforeMinify: (content) => {
// Custom pre-processing
return content;
},
onAfterMinify: (content) => {
// Custom post-processing
return content;
}
}
}))
.pipe(gulp.dest('dist'));
});🤝 Contributing
If you would like to contribute to the project, please create a pull request or leave feedback. We are always open to new ideas and improvements!
🐛 Issues
Found a bug? Want to request a feature? Please create an issue.
📄 License
This project is licensed under the MIT License. See the LICENSE file for details.
Made with ❤️ by Zilero
