-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.build.config.ts
42 lines (40 loc) · 1.35 KB
/
vite.build.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
* @Author: matiastang
* @Date: 2021-12-30 15:37:18
* @LastEditors: matiastang
* @LastEditTime: 2022-04-12 19:04:41
* @FilePath: /matias-axios-throttle/vite.build.config.ts
* @Description: npm 打包上传配置
*/
// vite配置文件vite.config.js
// node路径
import path from 'path'
// vite
import { defineConfig } from 'vite'
// 代码压缩
import { terser } from 'rollup-plugin-terser'
export default defineConfig({
// 插件
plugins: [terser()],
// 库模式
build: {
lib: {
entry: path.resolve(__dirname, './src/throttle/index.ts'),
name: 'matiasAxiosThrottle',
formats: ['es', 'cjs', 'umd', 'iife'],
fileName: (format) => `index.${format}.js`,
},
sourcemap: true, // 构建后是否生成 source map 文件。
// 自定义底层的 Rollup 打包配置。这与从 Rollup 配置文件导出的选项相同,并将与 Vite 的内部 Rollup 选项合并。查看 Rollup 选项文档 获取更多细节。
rollupOptions: {
// 确保外部化处理那些你不想打包进库的依赖
external: ['axios'],
output: {
// 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
globals: {
pinia: 'axios',
},
},
},
},
})