You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm willing to open a PR for allowing finer control over HTML minification with @web/rollup-plugin-html.
Primary motivation for this feature, in my case, is preserving <!--lit-part EeTSS7FUtCM=--> comments in Declarative Shadow DOM (from Lit SSR output), thanks to the ignoreCustomComments matcher option.
But I'm sure some other peeps will find benefits by exposing the minifier API, versus a simple ON/OFF toggle.
Change:
if(pluginOptions.minify){outputHtml=awaitminifyHTMLFunc(outputHtml,pluginOptions.minifyOptions
? pluginOptions.minifyOptions
: {collapseWhitespace: true,removeComments: true,removeRedundantAttributes: true,removeScriptTypeAttributes: true,removeStyleLinkTypeAttributes: true,useShortDoctype: true,minifyCSS: true,minifyJS: true,// Or maybe with a spread here? Like `...pluginOptions.minifyOptions`},);}
importtype{OptionsasHTMLMinifierOptions}from'html-minifier-terser';/** Whether to minify the output HTML. */
minify?: boolean;/** Minification options for HTML Minifier. */
minifyOptions?: HTMLMinifierOptions;
Association types from @types/html-minifier-terser.
/** Whether to extract and bundle assets referenced in HTML. Defaults to true. */
extractAssets?: boolean;
/** Whether to ignore assets referenced in HTML and CSS with glob patterns. */
externalAssets?: string|string[];
/** Define a full absolute url to your site (e.g. https://domain.com) */
absoluteBaseUrl?: string;
/** Whether to set full absolute urls for ['meta[property=og:image]', 'link[rel=canonical]', 'meta[property=og:url]'] or not. Requires a absoluteBaseUrl to be set. Default to true. */
absoluteSocialMediaUrls?: boolean;
/** Should a service worker registration script be injected. Defaults to false. */
injectServiceWorker?: boolean;
/** File system path to the generated service worker file */
serviceWorkerPath?: string;
/** Prefix to strip from absolute paths when resolving assets and scripts, for example when using a base path that does not exist on disk. */
absolutePathPrefix?: string;
/** When set to true, will insert meta tags for CSP and add script-src values for inline scripts by sha256-hashing the contents */
strictCSPInlineScripts?: boolean;
/** Bundle assets reference from CSS via `url` */
bundleAssetsFromCss?: boolean;
}
What do you think?
Thank you.
The text was updated successfully, but these errors were encountered:
I'd rather expose a way to override the minify function with a simple interface, seems like it fits well with the current design of the plugin. Can even be the same option set to a callback instead of a boolean:
pluginOptions.minify=(html)=>{constminifiedHtml=/* process html */returnminifiedHtml;}
Hello,
I'm willing to open a PR for allowing finer control over HTML minification with
@web/rollup-plugin-html
.Primary motivation for this feature, in my case, is preserving
<!--lit-part EeTSS7FUtCM=-->
comments in Declarative Shadow DOM (from Lit SSR output), thanks to theignoreCustomComments
matcher option.But I'm sure some other peeps will find benefits by exposing the minifier API, versus a simple ON/OFF toggle.
Change:
in:
web/packages/rollup-plugin-html/src/output/getOutputHTML.ts
Lines 96 to 107 in efd8579
Change:
Association types from
@types/html-minifier-terser
.in:
web/packages/rollup-plugin-html/src/RollupPluginHTMLOptions.ts
Lines 13 to 48 in efd8579
What do you think?
Thank you.
The text was updated successfully, but these errors were encountered: