-
Notifications
You must be signed in to change notification settings - Fork 1
/
vite.config.js
49 lines (47 loc) · 1.12 KB
/
vite.config.js
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
43
44
45
46
47
48
49
/* eslint-disable import/no-extraneous-dependencies */
import { defineConfig } from 'vite';
import dtsPlugin from 'vite-plugin-dts';
import { readFileSync } from 'fs';
import path from 'path';
const { dependencies = {}, devDependencies = {} } = JSON.parse(readFileSync('./package.json'));
const rootPath = path.resolve();
const outDir = 'dist';
const external = Object.keys({ ...dependencies, ...devDependencies });
export default defineConfig({
test: {
watch: false,
include: '__test__/*.test.ts',
},
plugins: [dtsPlugin({
// skipDiagnostics: false,
// logDiagnostics: true,
beforeWriteFile(filePath, content) {
return {
filePath: filePath.replace(`${rootPath}/${outDir}/src`, `${rootPath}/${outDir}`),
content,
};
},
})],
esbuild: {
minify: true,
},
build: {
target: 'esnext',
minify: 'terser',
outDir,
emptyOutDir: true,
rollupOptions: {
output: {
globals: {
axios: 'axios',
},
},
external,
},
lib: {
entry: './src',
name: 'MockAxios',
formats: ['es', 'cjs', 'iife'],
},
},
});