-
Notifications
You must be signed in to change notification settings - Fork 44
Laravel 5 5.1 HTML Minifying
Garrett Grimm edited this page Feb 27, 2016
·
6 revisions
I recommend using Gulp, instead of a PHP package, to compress the HTML that gets generated by your Blade template files. It works very well and is very configurable. It uses gulp-htmlmin, which uses html-minifier.
var htmlmin = require('gulp-htmlmin');
var gulp = require('gulp');
gulp.task('compress', function() {
var opts = {
collapseWhitespace: true,
removeAttributeQuotes: true,
removeComments: true,
minifyJS: true,
ignoreCustomFragments: [/<\?php[\s\S]*?\?>/g]
};
return gulp.src('./storage/framework/views/*')
.pipe(htmlmin(opts))
.pipe(gulp.dest('./storage/framework/views/'));
});
$ gulp compress