Skip to content

Releases: arma-events/vite-plugin-srcset

v2.3.0

Choose a tag to compare

@DerZade DerZade released this 18 Dec 06:56
e3fd9b4

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

Choose a tag to compare

@DerZade DerZade released this 18 Dec 06:05
d4cf514

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

Full Changelog: v2.1.0...v2.2.0

v2.1.0

Choose a tag to compare

@DerZade DerZade released this 17 Dec 07:13
bb00c8f

Changed

  • Support Vite v6

Full Changelog: v2.0.1...v2.1.0

v2.0.1

Choose a tag to compare

@DerZade DerZade released this 09 Nov 12:45
c569d39

Full Changelog: v2.0.0...v2.0.1

Fixed

  • Stuff didn't work on windows 😅

v2.0.0

Choose a tag to compare

@DerZade DerZade released this 05 Nov 20:23
c6abe2a

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 SUFFIX constant since it is not used anymore internally
    The plugin can now handle other search parameters in addition to srcset. Therefore the SUFFIX constant 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 ?url import from vite.
  • A srcset import now allows additional parameters next to srcset. This enables you to match multiple configs with a single image.
  • Added loadFile parameter 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

Choose a tag to compare

@DerZade DerZade released this 08 Jun 19:40
359586d

Full Changelog: v1.1.2...v1.1.3

Fixed

  • Fixed dev server impl on windows

v1.1.2

Choose a tag to compare

@DerZade DerZade released this 22 Apr 20:42
c6cea42

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

Choose a tag to compare

@DerZade DerZade released this 09 Feb 00:29
ffbe29a

Fixed

  • Downgrade mime to version 3.0.0 to retain CommonJS build of this plugin (mime@4 does no longer support CommonJS)

Full Changelog: v1.1.0...v1.1.1

v1.1.0

Choose a tag to compare

@DerZade DerZade released this 08 Feb 20:22
dba7106

Changed

  • Small refactors

Fixed

  • Do not include ?srcset suffix in ids when selecting a config

Full Changelog: v1.0.1...v1.1.0

v1.0.1

Choose a tag to compare

@DerZade DerZade released this 26 Nov 19:33
54dc428

This version does not contain any changes and is only for testing the release workflow.