Astro integration for images and SVG compression.
Basic image and SVG compression integration for Astro 4. Uses:
First, install the @nrsk/astropress
package using your package manager.
npm install @nrsk/astropress
Then, apply the integration to your astro.config.* file using the integrations
property:
import { defineConfig } from 'astro/config'
import astropress from '@nrsk/astropress'
export default defineConfig({
integrations: [astropress()]
})
Note
Place astropress after all other integrations.
sharp and svgo are given reasonable defaults, but can be easily configured via the image.options
and svg.options
properties, which accept sharp and svgo options respectively.
Besides that you can specify dir
and out
options to configure the input and output directories.
import { defineConfig } from 'astro/config'
import astropress from '@nrsk/astropress'
export default defineConfig({
integrations: [
astropress({
image: {
dir: '/path/to/input/dir',
out: '/path/to/output/dir',
options // sharp options.
},
svg: {
dir: '/path/to/input/dir',
out: '/path/to/output/dir',
options // svgo options.
}
})
]
})
MIT.