UNPKG

instapack

Version:

All-in-one TypeScript and Sass compiler for web applications!

61 lines (60 loc) 1.87 kB
"use strict"; const html_minifier_1 = require("html-minifier"); const source_map_1 = require("source-map"); const minifierOptions = { caseSensitive: false, collapseBooleanAttributes: true, collapseInlineTagWhitespace: false, collapseWhitespace: true, conservativeCollapse: true, continueOnParseError: false, decodeEntities: false, html5: true, includeAutoGeneratedTags: true, keepClosingSlash: true, minifyCSS: false, minifyJS: false, minifyURLs: false, preserveLineBreaks: false, preventAttributesEscaping: false, processConditionalComments: false, removeAttributeQuotes: false, removeComments: true, removeEmptyAttributes: false, removeEmptyElements: false, removeOptionalTags: false, removeRedundantAttributes: true, removeScriptTypeAttributes: false, removeStyleLinkTypeAttributes: false, removeTagWhitespace: false, sortAttributes: false, sortClassName: false, trimCustomFragments: false, useShortDoctype: false }; module.exports = function (html) { let template = html_minifier_1.minify(html, minifierOptions).trim(); template = 'module.exports = ' + JSON.stringify(template); if (this.sourceMap) { const gen = new source_map_1.SourceMapGenerator({ file: this.resourcePath + '.js' }); gen.addMapping({ source: this.resourcePath, generated: { column: 0, line: 1 }, original: { column: 0, line: 1 } }); gen.setSourceContent(this.resourcePath, html); const sm = JSON.parse(gen.toString()); this.callback(null, template, sm); } else { this.callback(null, template); } };