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

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners