Use plugins with Vite
Use plugins with Vite in the Compiler guide.
shadow() takes the same list in plugins. The list is validated when shadow() is called, so a plugin without a unique name or a transform function fails at config load. Every module the Vite plugin compiles goes through the plugins, in dev, in a build and in an SSR transform (context.target is "ssr" there). Errors fail the build with the file, line and column; warnings go to Vite's warning log.
vite.config.tsts
import shadow from "@shadow-js/vite";
import { defineConfig } from "vite";
import { i18nExtractor } from "./i18n-extractor";
import { stripTestIds } from "./strip-test-ids";
export default defineConfig({
plugins: [shadow({ plugins: [stripTestIds, i18nExtractor()] })],
});
The Vite plugin compiles the files that its include option matches, and plain .ts modules only when they call useStore. A plugin that must see other modules (an extractor over .ts files) needs an include that covers them.