Skip to content

Commit 39f949b

Browse files
authored
Merge branch 'master' into feat-originalFileName-3008
2 parents ef0641b + 2a8feac commit 39f949b

23 files changed

Lines changed: 1615 additions & 72 deletions

File tree

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
permissions:
1616
contents: write
1717
id-token: write
18+
pull-requests: write
1819
steps:
1920
- name: Checkout Repo
2021
uses: actions/checkout@v4

docs/docs/building/rollup-plugin-html.md

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ export default {
273273
};
274274
```
275275

276-
### Minification
276+
### HTML minification
277277

278278
Set the minify option to do default HTML minification. If you need custom options, you can implement your own minifier using the `transformHtml` option.
279279

@@ -292,6 +292,31 @@ export default {
292292
};
293293
```
294294

295+
### CSS bundling and minification
296+
297+
It's implemented via [Lightning CSS](https://lightningcss.dev/).
298+
It works when `extractAssets: true` and CSS files are extracted.
299+
300+
CSS bundling is enabled by default.
301+
Set `bundleCss: false` to disable it.
302+
303+
CSS minification can be enabled by setting `minifyCss: true`.
304+
305+
```js
306+
import { rollupPluginHTML as html } from '@web/rollup-plugin-html';
307+
308+
export default {
309+
input: 'index.html',
310+
output: { dir: 'dist' },
311+
plugins: [
312+
// add HTML plugin
313+
html({
314+
minifyCss: true,
315+
}),
316+
],
317+
};
318+
```
319+
295320
### Social Media Tags
296321

297322
Some social media tags require full absolute URLs (e.g. https://domain.com/guide/).
@@ -379,11 +404,11 @@ export interface InputHTMLOptions {
379404
export interface RollupPluginHTMLOptions {
380405
/** HTML file(s) to use as input. If not set, uses rollup input option. */
381406
input?: string | InputHTMLOptions | (string | InputHTMLOptions)[];
382-
/** HTML file glob patterns or patterns to ignore */
407+
/** HTML file glob pattern or patterns to ignore */
383408
exclude?: string | string[];
384-
/** Whether to minify the output HTML. */
409+
/** Whether to minify the output HTML. Defaults to false. */
385410
minify?: boolean;
386-
/** Whether to preserve or flatten the directory structure of the HTML file. */
411+
/** Whether to preserve or flatten the directory structure of the HTML file. Defaults to true. */
387412
flattenOutput?: boolean;
388413
/** Directory to resolve absolute paths relative to, and to use as base for non-flatted filename output. */
389414
rootDir?: string;
@@ -393,13 +418,17 @@ export interface RollupPluginHTMLOptions {
393418
transformAsset?: TransformAssetFunction | TransformAssetFunction[];
394419
/** Transform HTML file before output. */
395420
transformHtml?: TransformHtmlFunction | TransformHtmlFunction[];
396-
/** Whether to extract and bundle assets referenced in HTML. Defaults to true. */
421+
/** Whether to extract and bundle assets referenced in HTML and CSS. Defaults to true. */
397422
extractAssets?: boolean | 'legacy-html' | 'legacy-html-and-css';
423+
/** Whether to bundle extracted CSS assets. Bundling is done via Lightning CSS. Defaults to true. */
424+
bundleCss?: boolean;
425+
/** Whether to minify extracted CSS assets. Minificaiton is done via Lightning CSS. Defaults to false. */
426+
minifyCss?: boolean;
398427
/** Whether to ignore assets referenced in HTML and CSS with glob patterns. */
399428
externalAssets?: string | string[];
400429
/** Define a full absolute url to your site (e.g. https://domain.com) */
401430
absoluteBaseUrl?: string;
402-
/** 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. */
431+
/** 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. Defaults to true. */
403432
absoluteSocialMediaUrls?: boolean;
404433
/** Should a service worker registration script be injected. Defaults to false. */
405434
injectServiceWorker?: boolean;

0 commit comments

Comments
 (0)