Skip to content

Instantly share code, notes, and snippets.

@ratson
Last active December 9, 2019 03:52
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ratson/3fa6ed459c6770f02767 to your computer and use it in GitHub Desktop.
Save ratson/3fa6ed459c6770f02767 to your computer and use it in GitHub Desktop.
Minify Hugo Generated HTML
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)
})
{
"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