Skip to content

Commit abdd6de

Browse files
committed
Improve html-minifier's options.
1 parent 8f2b5a9 commit abdd6de

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

build.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,33 @@ const markedOptions = {
4747
renderer
4848
}
4949

50+
const htmlMinifierOpts = {
51+
collapseBooleanAttributes: true,
52+
collapseWhitespace: true,
53+
conservativeCollapse: true, // This is needed as things are now
54+
decodeEntities: true,
55+
minifyCSS: {
56+
level: {
57+
1: {
58+
specialComments: 0
59+
}
60+
}
61+
},
62+
minifyJS: false, // we don't have a lot inline JS and this slows down things
63+
minifyURLs: false,
64+
processConditionalComments: true,
65+
removeAttributeQuotes: true,
66+
removeComments: true,
67+
removeOptionalAttributes: true,
68+
removeOptionalTags: true,
69+
removeRedundantAttributes: true,
70+
removeScriptTypeAttributes: true,
71+
removeStyleLinkTypeAttributes: true,
72+
removeTagWhitespace: false,
73+
sortAttributes: true,
74+
sortClassName: true
75+
}
76+
5077
// This function imports a given language file and uses the default language set
5178
// in DEFAULT_LANG as a fallback to prevent any strings that aren't filled out
5279
// from appearing as blank.
@@ -181,7 +208,7 @@ function buildLocale (source, locale, opts) {
181208
}))
182209
.use(layouts())
183210
// Use the default options
184-
.use(htmlMinifier())
211+
.use(htmlMinifier({ minifierOptions: htmlMinifierOpts }))
185212
// Pipes the generated files into their respective subdirectory in the build
186213
// directory.
187214
.destination(path.join(__dirname, 'build', locale))

0 commit comments

Comments
 (0)