vite-plugin-singlefile-compression
Version:
Compress all assets and embeds them into `dist/index.html`, making it convenient to share as a single HTML file.
26 lines (25 loc) • 1.04 kB
JavaScript
export const defaultHtmlMinifierTerserOptions = {
removeAttributeQuotes: true,
removeComments: true,
collapseWhitespace: true,
removeOptionalTags: true,
removeRedundantAttributes: true,
minifyJS: false,
};
export function getInnerOptions(opt) {
opt ||= {};
return {
rename: opt.rename && opt.rename.replace(/(\.(html?)?)?$/, '.html'),
htmlMinifierTerser: opt.htmlMinifierTerser == null || opt.htmlMinifierTerser === true
? defaultHtmlMinifierTerserOptions
: opt.htmlMinifierTerser,
tryInlineHtmlAssets: opt.tryInlineHtmlAssets ?? true,
removeInlinedAssetFiles: opt.removeInlinedAssetFiles ?? true,
tryInlineHtmlPublicIcon: opt.tryInlineHtmlPublicIcon ?? true,
removeInlinedPublicIconFiles: opt.removeInlinedPublicIconFiles ?? true,
useBase128: opt.useBase128 ?? true,
compressFormat: ["deflate-raw", "deflate", "gzip"].includes(opt.compressFormat)
? opt.compressFormat
: "deflate-raw",
};
}