Skip to content

Commit

Permalink
0.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaRHristov committed Jun 7, 2022
1 parent 5c55bc1 commit 0f70396
Show file tree
Hide file tree
Showing 21 changed files with 1,169 additions and 904 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.0.9

- Refactor
- Introduces svgo svg processing

## 0.0.8

- Updates README.md
Expand Down
51 changes: 46 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This **[Astro integration][astro-integration]** brings compression utilities to
your Astro project.

[csso] [html-minifier-terser] [terser] [sharp]
[csso] [html-minifier-terser] [terser] [sharp] [svgo]

## Installation

Expand Down Expand Up @@ -58,12 +58,36 @@ export default defineConfig({
The utility should now automatically compress all your CSS, HTML and JavaScript
files in the dist folder.

The following image file types will also be compressed.

- avci
- avcs
- avif
- avifs
- gif
- heic
- heics
- heif
- heifs
- jfif
- jif
- jpe
- jpeg
- jpg
- png
- raw
- tiff
- webp

SVG compression is supported, as well via [svgo].

You can override any of the default options from the configurations of:

- [csso](src/options/csso.ts)
- [html-minifier-terser](src/options/html-minifier-terser.ts)
- [terser](src/options/terser.ts)
- [sharp](src/options/sharp.ts)
- [csso](src/options/css.ts)
- [html-minifier-terser](src/options/html.ts)
- [terser](src/options/js.ts)
- [sharp](src/options/img.ts)
- [svgo](src/options/svg.ts)

or disable them entirely:

Expand All @@ -78,6 +102,7 @@ export default defineConfig({
html: false,
js: false,
img: false,
svg: false,
}),
],
});
Expand All @@ -99,9 +124,25 @@ export default defineConfig({
});
```

Set logger to 0 if you do not want to see debug messages. Default is 2.

```js
import { defineConfig } from "astro/config";
import compress from "astro-compress";

export default defineConfig({
integrations: [
compress({
logger: 0,
}),
],
});
```

[astro-compress]: https://npmjs.org/astro-compress
[csso]: https://npmjs.org/csso
[html-minifier-terser]: https://npmjs.org/html-minifier-terser
[terser]: https://npmjs.org/terser
[sharp]: https://npmjs.org/sharp
[svgo]: https://npmjs.org/svgo
[astro-integration]: https://docs.astro.build/en/guides/integrations-guide/
2 changes: 1 addition & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 15 additions & 9 deletions dist/options.d.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
import CSS from "./options/csso";
import HTML from "./options/html-minifier-terser";
import JS from "./options/terser";
import IMG from "./options/sharp";
import CSS from "./options/css";
import HTML from "./options/html";
import JS from "./options/js";
import IMG from "./options/img";
import SVG from "./options/svg";
export default interface Options {
[key: string]: any;
/**
* Astro build path.
* Default: "./dist/"
* @default "./dist/"
*/
path?: string;
/**
* [csso] options.
*/
css?: CSS;
css?: boolean | CSS;
/**
* [html-minifier-terser] options.
*/
html?: HTML;
html?: boolean | HTML;
/**
* [terser] options.
*/
js?: JS;
js?: boolean | JS;
/**
* [sharp] options.
*/
img?: IMG;
img?: boolean | IMG;
/**
* [svgo] options.
*/
svg?: boolean | SVG;
/**
* Logger level.
* Default: 2
Expand Down
23 changes: 12 additions & 11 deletions dist/options/csso.d.ts → dist/options/css.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,62 +7,63 @@ export interface afterCompressOptions {
options?: {};
}
export default interface CSS {
[key: string]: any;
/**
* Generate a source map when true.
* Default: false
* @default false
*/
sourceMap?: Boolean;
/**
* Filename of input CSS, uses for source map generation.
* Default: '<unknown>'
* @default '<unknown>'
*/
filename?: String;
/**
* Output debug information to stderr.
* Default: false
* @default false
*/
debug?: Boolean;
/**
* Called right after parse is run.
* Default: null
* @default null
*/
beforeCompress?: ({}: beforeCompressOptions) => void | Array<({}: beforeCompressOptions) => void> | null;
/**
* Called right after syntax.compress() is run.
* Default: null
* @default null
*/
afterCompress?: ({}: afterCompressOptions) => void | Array<({}: afterCompressOptions) => void> | null;
/**
* Disable | enable a structure optimisations.
* Default: true
* @default true
*/
restructure?: Boolean;
/**
* Enables merging of @media rules with the same media query by splitted by other rules.
* The optimisation is unsafe in general, but should work fine in most cases. Use it on your own risk.
* Default: false
* @default false
*/
forceMediaMerge?: Boolean;
/**
* Transform a copy of input AST if true. Useful in case of AST reuse.
* Default: false
* @default false
*/
clone?: Boolean;
/**
* Specify what comments to leave:
* 'exclamation' | true – leave all exclamation comments (i.e. /*! .. *\/)
* 'first-exclamation' – remove every comment except first one false – remove all comments
* Default: true
* @default true
*/
comments?: String | Boolean;
/**
* Usage data for advanced optimisations.
* Default: null
* @default null
*/
usage?: {} | null;
/**
* Function to track every step of transformation.
* Default: null
* @default null
*/
logger?: () => {} | null;
}
Loading

0 comments on commit 0f70396

Please sign in to comment.