A Vite plugin that integrates Prism.js syntax highlighting by processing JavaScript imports to include only specified languages, plugins, and themes. Version 0.0.11 (latest as of 2023) targets Node >=12 and ships TypeScript definitions. It works at transform time to reduce bundle size. Compared to manual Prism.js setup, it automates language registration and avoids unnecessary imports. The plugin mirrors the configuration of babel-plugin-prismjs, making migration straightforward for projects switching from Babel to Vite.
npm install vite-plugin-prismjsVerified import paths — ran on the pinned version, not inferred.
Configures Vite to use the prismjs plugin with three languages, two plugins, and the okaidia theme, enabling CSS injection.
Specify only needed languages as an array.
Set css: false if you handle styles separately.
Ensure Prism.js is imported in a JavaScript/TypeScript module that is processed by Vite.
Use import prismjs from 'vite-plugin-prismjs'.
Run npm install prismjs.
Use import prismjs from 'vite-plugin-prismjs'.