-
-
Save ratson/3fa6ed459c6770f02767 to your computer and use it in GitHub Desktop.
Minify Hugo Generated HTML
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gulp from 'gulp' | |
import htmlmin from 'gulp-htmlmin' | |
import runSequence from 'run-sequence' | |
import shell from 'gulp-shell' | |
gulp.task('hugo-build', shell.task(['hugo'])) | |
gulp.task('minify-html', () => { | |
return gulp.src('public/**/*.html') | |
.pipe(htmlmin({ | |
collapseWhitespace: true, | |
minifyCSS: true, | |
minifyJS: true, | |
removeComments: true, | |
useShortDoctype: true, | |
})) | |
.pipe(gulp.dest('./public')) | |
}) | |
gulp.task('build', ['hugo-build'], (callback) => { | |
runSequence('minify-html', callback) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"private": true, | |
"scripts": { | |
"build": "gulp build" | |
}, | |
"devDependencies": { | |
"babel-preset-es2015": "^6.5.0", | |
"babel-register": "^6.5.2", | |
"gulp": "^3.9.1", | |
"gulp-cli": "^1.2.1", | |
"gulp-htmlmin": "^1.3.0", | |
"gulp-shell": "^0.5.2", | |
"run-sequence": "^1.1.5" | |
}, | |
"babel": { | |
"presets": [ | |
"es2015" | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment