Dark mode
Using Plugins
Available Plugins
Official Plugins
ปลั๊กอิน | คําอธิบาย |
---|---|
สําหรับ Vue 3 Single File Components | |
สําหรับ Vue 3 JSX | |
สําหรับ Vue 2 JSX | |
สําหรับ React | |
สําหรับ React ด้วย SWC | |
สําหรับรองรับ Legacy Browsers |
Community Plugins
Recommended Plugins
Vite Plugins ทั่วไป
Plugins | รายละเอียด |
---|---|
ตรวจจับและรายงานไฟล์ที่ไม่ได้ใช้งานในโปรเจกต์ | |
CSS Engine แบบ Atomic ที่รวดเร็วและยืดหยุ่น คล้าย Tailwind แต่ไม่ต้อง PostCSS | |
บีบอัดรูปภาพให้มีขนาดเล็กลงโดยอัตโนมัติ | |
ตรวจสอบ Type และ Lint ในขณะ development โดยใช้ worker thread | |
ช่วยแปลง UTC เป็น local time โดยอัตโนมัติในระหว่าง build time | |
รองรับการใช้งาน path aliases ที่กำหนดใน tsconfig.json | |
บีบอัดรูปภาพอัตโนมัติระหว่างการ build เพื่อเพิ่มประสิทธิภาพของเว็บไซต์ |
Vue Plugins
Plugins | รายละเอียด |
---|---|
เครื่องมือพัฒนา Vue ที่เพิ่มประสิทธิภาพในการ debug และวิเคราะห์แอพ Vue | |
ช่วยจัดการตัวแปร CSS ใน Vue components โดยสร้าง CSS variables จาก script setup |
Creating Plugins
bash
plugins/
├── dist/index.js # ไฟล์ผลลัพธ์ที่ถูก compile แล้ว
├── src/
│ └── index.ts # Source code ของ plugin
├── package.json # ไฟล์กำหนดค่า package
└── tsconfig.json # ตั้งค่า TypeScript
├── src/ # โค้ดต้นฉบับ
│ └── my-plugin.ts
└── vite.config.ts # ไฟล์กำหนดค่า plugin
ts
import type { Plugin } from "vite";
interface MyPluginOptions {
message?: string;
debug?: boolean;
}
export default function myPlugin(options: MyPluginOptions = {}): Plugin {
return {
name: "my-plugin",
enforce: "pre",
configResolved(config) {
if (options.debug) {
console.log("Config resolved:", config.mode);
}
},
configureServer(server) {
server.middlewares.use((req, res, next) => {
next();
});
},
transform(code, id) {
if (id.endsWith(".js")) {
return {
code: `/* ${options.message || "Processed by my-plugin"} */\n${code}`,
map: null,
};
}
},
closeBundle() {
console.log("Build completed!");
},
};
}
ts
import myPlugin from "./plugins/src/my-plugin";
export default {
plugins: [myPlugin({ message: "Hello", debug: true })],
};