重要配置项
entryPoints:字符串数组指定打包的多个起点outfile:'输出的文件路径'- 这仅在单个入口点时适用。
- 如果有多个入口点,你必须适用 outdir 配置项来制定输出文件夹。
bundle:true才会递归的打包依赖文件platform: node|browser|neutral如果使用了nodejs的内置模块, 需要设置为node- 默认为browser
- child::external配置项
watch: 布尔值是否启用热打包sourcemap: 布尔值是否启用sourcemap功能treeShaking: 布尔值是否启用Vite treeShaking功能banner: 对象为打包出来的文件添加任意字符串(通常用来添加注释)- 键名为目标文件格式(如js, css)
- 值为添加到开头的字符串
format: "esm"|"cjs"设置打包生成的文件使用什么JS的模块化规范
1. 一般配置项:
- Bundle
- Define
- Entry points
- External
- Format
- Inject
- Loader
- Minify
- Outdir
- Outfile
- Platform
- Serve
- Sourcemap
- Target
- Watch
- Write
2. 高级配置:
- Allow overwrite
- Analyze
- Banner
- Charset
- Conditions
- Footer
- Ignore annotations
- JSX
- JSX factory
- JSX fragment
- Keep names
- Legal comments
- Main fields
- Metafile
- Node paths
- Out extension
- Outbase
- Preserve symlinks
- Public path
- Pure
- Resolve extensions
- Source Root
- Sourcefile
- Sources Content
- Stdin
- Tree shaking
- Tsconfig
- Working directory