Skip to content

Releases: arma-events/vite-plugin-srcset

v2.1.0

17 Dec 07:13
bb00c8f
Compare
Choose a tag to compare

Changed

  • Support Vite v6

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

v2.0.1

09 Nov 12:45
c569d39
Compare
Choose a tag to compare

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

Fixed

  • Stuff didn't work on windows 😅

v2.0.0

05 Nov 20:23
c6abe2a
Compare
Choose a tag to compare

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

08 Jun 19:40
359586d
Compare
Choose a tag to compare

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

Fixed

  • Fixed dev server impl on windows

v1.1.2

22 Apr 20:42
c6cea42
Compare
Choose a tag to compare

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

09 Feb 00:29
ffbe29a
Compare
Choose a tag to compare

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

08 Feb 20:22
dba7106
Compare
Choose a tag to compare

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

26 Nov 19:33
54dc428
Compare
Choose a tag to compare

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

v1.0.0

26 Nov 19:17
dbdc307
Compare
Choose a tag to compare

Initial release