Befly Vite
raw JSON → 1.6.0 verified Mon Apr 27 auth: no javascript
Befly Vite 配置预设和插件集合,专为 Vue 3 项目优化,提供开箱即用的 Vite 配置。当前版本 1.6.0,活跃开发中。集成了常用插件(路由、自动导入、图标等)、优化的构建配置(分包、压缩、分析),并支持自定义扩展。与 Vue 3 和 Vite 深度集成,适合快速搭建 Vue 3 项目。注意:需要 Bun >= 1.3.0 作为运行时。
Common errors
error SyntaxError: Cannot use import statement outside a module ↓
cause Using ESM import in a CommonJS context (e.g., without `"type": "module"` in package.json).
fix
Add
"type": "module" to package.json or rename file to .mjs. error Error [ERR_REQUIRE_ESM]: require() of ES Module ↓
cause Attempting to require() the package which is ESM-only.
fix
Use import syntax instead of require().
error Unsupported engine: befly-vite requires bun >=1.3.0 ↓
cause Running npm install with Node.js or an older version of Bun.
fix
Install Bun 1.3.0+ and use
bun install. Warnings
gotcha Package requires Bun >=1.3.0; Node.js is not supported. ↓
fix Install Bun 1.3.0 or later and use `bun` command instead of `node`.
breaking ESM-only package; CommonJS require() will throw a runtime error. ↓
fix Use ES module import syntax; set `"type": "module"` in package.json or use .mjs extension.
gotcha Automatic exclusion of `**/components/**` from befly-admin-ui views routing may cause missing routes. ↓
fix If using befly-admin-ui, ensure view files are not under components directory; override exclusion in custom config if needed.
Install
npm install befly-vite yarn add befly-vite pnpm add befly-vite Imports
- createBeflyViteConfig wrong
const createBeflyViteConfig = require('befly-vite')correctimport { createBeflyViteConfig } from 'befly-vite' - default export
export { default } from 'befly-vite' - type definitions wrong
import { BeflyViteOptions } from 'befly-vite'correctimport type { BeflyViteOptions } from 'befly-vite'
Quickstart
// vite.config.js
import { createBeflyViteConfig } from 'befly-vite';
export default createBeflyViteConfig();