buiildToolStudy/viteTest
shenjianZ 4f92af3360 feat vite feature 2024-07-30 14:49:42 +08:00
..
README.md feat vite feature 2024-07-30 14:49:42 +08:00
index.html feat vite feature 2024-07-30 14:49:42 +08:00
index.js feat vite feature 2024-07-30 14:49:42 +08:00
package-lock.json feat vite feature 2024-07-30 14:49:42 +08:00
package.json feat vite feature 2024-07-30 14:49:42 +08:00
vite.config.js feat vite feature 2024-07-30 14:49:42 +08:00

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