Source: paulund.co.uk

Add Prism.js using Vite
#introductionPrismJS is a lightweight, extensible syntax highlighter that is used to highlight code snippets on web pages. #installationTo add PrismJS to your Vite project, you need to install the prismjs package and the @types/prismjs package for TypeScript support.

You can do this by adding the following code to your vite.config.ts file: import { defineConfig } from 'vite'; import prism from 'vite-plugin-prismjs'; export default defineConfig({ plugins: [ prism({ languages: ['javascript', 'css', 'html', 'typescript'], plugins: ['line-numbers'], theme: 'tomorrow', css: true, }), ], }); This code configures the Prism Plugin to use the tomorrow theme and the line-numbers plugin.

You can do this by adding the following code to your main.ts or main.js file: import 'prismjs/themes/prism-tomorrow.css'; import 'prismjs/plugins/line-numbers/prism-line-numbers.css'; import 'prismjs'; This code imports the tomorrow theme and the line-numbers plugin CSS files, as well as the PrismJS JavaScript file. You can now use PrismJS to highlight code snippets in your project.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners