Compare commits
2 Commits
cc7c6fca3d
...
45a672360b
Author | SHA1 | Date | |
---|---|---|---|
45a672360b | |||
36165d1340 |
95
README.md
95
README.md
@ -1,19 +1,94 @@
|
||||
Minify your static Astro site.
|
||||
# [@zokki/astro-minify]
|
||||
|
||||
This package helps you minify HTML, CSS, and SVG files within your static Astro site, resulting in a smaller bundle size and potentially faster loading times.
|
||||
|
||||
> **Note**
|
||||
>
|
||||
> `astro-minify` only for statically generated build and pre-rendered routes.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install @zokki/astro-minify
|
||||
```
|
||||
1. Install with npm.
|
||||
|
||||
## Usage
|
||||
```bash
|
||||
npm install @zokki/astro-minify
|
||||
```
|
||||
|
||||
Import into the astro-config. The integration should be below most of the other integrations.
|
||||
2. Import into the astro-config. The integration should be below most of the other integrations.
|
||||
|
||||
```ts
|
||||
import { minify } from '@zokki/astro-minify';
|
||||
|
||||
export default defineConfig({
|
||||
integrations: [minify()],
|
||||
});
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
```ts
|
||||
import { minify } from '@zokki/astro-minify';
|
||||
/**
|
||||
* Toggle logging of all minified files
|
||||
*
|
||||
* @default
|
||||
* true
|
||||
*/
|
||||
logAllFiles?: boolean;
|
||||
|
||||
export default defineConfig({
|
||||
integrations: [minify()],
|
||||
});
|
||||
/**
|
||||
* Config for `@minify-html/node` or `false` to disable html minification
|
||||
*
|
||||
* @default
|
||||
* {
|
||||
* minify_css: true,
|
||||
* minify_js: true,
|
||||
* keep_comments: false,
|
||||
* keep_ssi_comments: false,
|
||||
* keep_closing_tags: true
|
||||
* }
|
||||
*/
|
||||
html?: false | MinifyHtmlConfig;
|
||||
|
||||
/**
|
||||
* Config for `lightningcss` or `false` to disable css minification
|
||||
*
|
||||
* @default
|
||||
* { minify: true }
|
||||
*/
|
||||
css?: false | LightningcssConfig;
|
||||
|
||||
/**
|
||||
* Config for `svgo` or `false` to disable svg minification
|
||||
*
|
||||
* @default
|
||||
* {
|
||||
* multipass: true,
|
||||
* plugins: [
|
||||
* {
|
||||
* name: 'preset-default',
|
||||
* params: {
|
||||
* overrides: {
|
||||
* // disable a default plugin
|
||||
* cleanupIds: false,
|
||||
* removeHiddenElems: false,
|
||||
* removeEmptyContainers: false,
|
||||
* },
|
||||
* },
|
||||
* },
|
||||
* ],
|
||||
* }
|
||||
*/
|
||||
svg?: false | SvgoConfig;
|
||||
|
||||
/**
|
||||
* Config for cids-replacement or `false` to disable svg minification
|
||||
*
|
||||
* @default
|
||||
* {
|
||||
* prefix: 'z-',
|
||||
* cidRegex: /data-astro-cid-[a-zA-Z0-9]{7,10}/g,
|
||||
* extensions: ['html', 'css']
|
||||
* }
|
||||
*/
|
||||
minifyCid?: false | MinifyCidConfig;
|
||||
```
|
||||
|
@ -137,7 +137,7 @@ export const minify = (config?: MinifyConfig): AstroIntegration => ({
|
||||
.then(() => {
|
||||
if (originalSizeSum) {
|
||||
const reduction = reductionMessage(originalSizeSum, minifiedSizeSum);
|
||||
logger.info(`Minification done! (total minfication: ${reduction})`);
|
||||
logger.info(`Minification done! (total minification: ${reduction})`);
|
||||
} else {
|
||||
logger.info('Nothing to minify!');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user