|
|
||
|---|---|---|
| .. | ||
| README.md | ||
| index.html | ||
| index.js | ||
| package-lock.json | ||
| package.json | ||
| vite.config.js | ||
README.md
初始化项目
npm init -y
安装vite (开发依赖)
npm add -D vite
运行 vite 项目
npx vite
打包 vite 项目
npx vite build
启动预览服务器
npx vite preview
此外可以使用命令一键创建 vite 项目模板
npm create vite@latest
在 vite.config.js 中配置插件
添加插件
npm add -D @vitejs/plugin-legacy
配置插件
// vite.config.js
import image from '@rollup/plugin-image'
import { defineConfig } from 'vite'
export default defineConfig({
plugins: [
{
...image(),
enforce: 'pre',
},
],
})
配置vite
import { defineConfig } from 'vite'
const config = defineConfig({
})
export default config