Skip to content

Commit 8f2b5a9

Browse files
nschonniXhmikosR
authored andcommitted
feat: minify HTML on build
1 parent 06686ec commit 8f2b5a9

3 files changed

Lines changed: 107 additions & 5 deletions

File tree

build.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const markdown = require('metalsmith-markdown')
1616
const prism = require('metalsmith-prism')
1717
const permalinks = require('metalsmith-permalinks')
1818
const pagination = require('metalsmith-yearly-pagination')
19+
const htmlMinifier = require('metalsmith-html-minifier')
1920
const defaultsDeep = require('lodash.defaultsdeep')
2021
const autoprefixer = require('autoprefixer')
2122
const marked = require('marked')
@@ -179,6 +180,8 @@ function buildLocale (source, locale, opts) {
179180
pattern: /\.js$/
180181
}))
181182
.use(layouts())
183+
// Use the default options
184+
.use(htmlMinifier())
182185
// Pipes the generated files into their respective subdirectory in the build
183186
// directory.
184187
.destination(path.join(__dirname, 'build', locale))

package-lock.json

Lines changed: 103 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"metalsmith-discover-helpers": "^0.1.1",
5151
"metalsmith-discover-partials": "^0.1.2",
5252
"metalsmith-feed": "^1.0.0",
53+
"metalsmith-html-minifier": "^4.0.0",
5354
"metalsmith-layouts": "^2.3.1",
5455
"metalsmith-markdown": "^1.3.0",
5556
"metalsmith-metadata": "0.0.4",

0 commit comments

Comments
 (0)