Releases: arma-events/vite-plugin-srcset
Release list
v2.3.0
This release does not include any changes. Its sole purpose is to set up trusted publishing for npm.
Full Changelog: v2.2.0...v2.3.0
v2.2.0
Semi breaking changes
Note
Note that this release updates the default image output settings. Previously, images were written to disk using lossless encoding with a quality setting of 100% ({ quality: 100, lossless: true }), which often resulted in very large file sizes.
The new default uses { effort: 4 } for all formats. This may slightly reduce image quality, but produces much more reasonable output sizes.
Added
outputOptionsByFormatoption to control output options passed to sharp when writing images (see docs)
Full Changelog: v2.1.0...v2.2.0
v2.1.0
v2.0.1
v2.0.0
Highlights
This version adds a loadFile function in your options, which allows you to modify the source file before the srcset is generated. Additionally you can now use other search params and even filter by them in the include option:
// vite.config.ts
import { readFile } from 'fs/promises';
import { defineConfig } from 'vite';
import srcset from 'vite-plugin-srcset';
export default defineConfig({
plugins: [
srcset(
// ORDER OF CONFIGS MATTER!! The first matching config is used
// SVGs but all black fills are replaced with white
{
include: '**/*.svg?white=true',
async loadFile(id: string) {
const fsPath = new URL(id, import.meta.url).pathname;
let text = await readFile(fsPath, 'utf-8');
text = text.replaceAll('fill="black"', 'fill="white"');
return { contents: Buffer.from(text, 'utf-8') };
}
},
// normal SVGs
{
include: '**/*.svg',
},
)
]
});import iconBlackSrcSet from './icon.svg?srcset';
import iconWhiteSrcSet from './icon.svg?white=true&srcset';Breaking Changes
- Removed export of
SUFFIXconstant since it is not used anymore internally
The plugin can now handle other search parameters in addition tosrcset. Therefore theSUFFIXconstant was removed in its entirety. Check out this commit to see how the new logic is implemented - Plugin now takes multiple configs as individual parameters instead of one array parameter
To migrate, simply remove the square braces around your config:// vite.config.ts export default defineConfig({ plugins: [ - srcset([ + srcset( { // config 1 (see below for list of options) }, { // config 2 (see below for list of options) }, // [...] - ]), + ), // [...] ] });
All Changes
- During development a Data URL is used instead of a
?urlimport from vite. - A srcset import now allows additional parameters next to
srcset. This enables you to match multiple configs with a single image. - Added
loadFileparameter to options - The plugin factory now takes multiple config parameters instead of one array parameter containing multiple configs
- Updated most dependencies
Full Changelog: v1.1.3...v2.0.0
v1.1.3
v1.1.2
Full Changelog: v1.1.1...v1.1.2
This release does not include any changes. Its sole purpose is to set up provenance statements for npm.
v1.1.1
Fixed
- Downgrade
mimeto version3.0.0to retain CommonJS build of this plugin (mime@4does no longer support CommonJS)
Full Changelog: v1.1.0...v1.1.1
v1.1.0
Changed
- Small refactors
Fixed
- Do not include
?srcsetsuffix in ids when selecting a config
Full Changelog: v1.0.1...v1.1.0