Skip to content

Interaction with Vite transformIndexHtml plugin #12391

Description

@fcrozatier

Describe the bug

I'm not sure if this is desired or not or a documentation thing.
For some reason Vite transformIndexHtml plugins do not run.

Reproduction

Just paste this inside a vite.config.ts

import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig, type Plugin } from 'vite';

const htmlPlugin = () => {
 console.log('plugin init');
 return {
  name: 'html-transform',
  transformIndexHtml(html) {
   console.log('plugin transform'); // Never runs
   return html.replace(/<title>(.*?)<\/title>/, `<title>Title replaced!</title>`);
   }
  } satisfies Plugin;
};

export default defineConfig({
 plugins: [htmlPlugin(), sveltekit()]
});

Logs

No response

System Info

System:
    OS: macOS 14.5
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 16.11 GB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.0 - ~/.nvm/versions/node/v20.11.0/bin/node
    Yarn: 1.22.22 - /usr/local/bin/yarn
    npm: 10.2.4 - ~/.nvm/versions/node/v20.11.0/bin/npm
    pnpm: 9.4.0 - ~/Library/pnpm/pnpm
  Browsers:
    Brave Browser: 126.1.67.119
    Chrome: 126.0.6478.63
    Safari: 17.5

Severity

annoyance

Additional Information

Why is this happening?

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature / enhancementNew feature or requestneeds-decisionNot sure if we want to do this yet, also design work needed

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions