Skip to content

Latest commit

 

History

History
20 lines (14 loc) · 830 Bytes

File metadata and controls

20 lines (14 loc) · 830 Bytes
type lesson
title Defining a custom plugin
focus /vite.config.ts
template
name visibleFiles
default
/content.yaml
/index.js
vite.config.ts

Defining a custom plugin

A plugin is a plain object that defines hooks to modify the way Vite resolves ids, loads and transforms modules, and more. It can have various properties that are listed in the Plugin API | Vite documentation. The only required property is name.

Let's start by adding a custom plugin in our Vite config file. To do this, add a new plugins array property in the exported config object.

Then, let's add a new object with name 'yaml-plugin' inside the plugins array.

A successfully defined plugin should be reported in the Preview tab:

Loaded Vite plugins: yaml-plugin ✅