diff --git a/client/build.js b/client/build.js index 80a7cf3c..81fc1893 100644 --- a/client/build.js +++ b/client/build.js @@ -58,28 +58,33 @@ function getConfig() { function bundleHtml(config) { const minify = require('html-minifier').minify; const baseHtml = fs.readFileSync('./html/index.htm', 'utf-8'); + const minifyOptions = { + removeComments: true, + collapseWhitespace: true, + conservativeCollapse: true, + }; glob('./html/**/*.hbs', {}, (er, files) => { - let templatesHtml = ''; + let templates = {}; for (const file of files) { - templatesHtml += util.format( - '%s', - path.basename(file, '.hbs').replace(/_/g, '-'), - fs.readFileSync(file)); + const name = path.basename(file, '.hbs').replace(/_/g, '-'); + templates[name] = minify( + fs.readFileSync(file, 'utf-8'), minifyOptions); } + const templatesHolder = util.format( + '', + JSON.stringify(templates)); + const finalHtml = baseHtml - .replace(/(<\/head>)/, templatesHtml + '$1') + .replace(/(<\/head>)/, templatesHolder + '$1') .replace( /(