-
Notifications
You must be signed in to change notification settings - Fork 8
/
vite.config.ts
65 lines (61 loc) · 1.43 KB
/
vite.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// import { fileURLToPath, URL } from 'node:url'
import path from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import dts from 'vite-plugin-dts'
import pkg from './package.json'
const createBanner = () => {
return `/*!
* ${pkg.name} v${pkg.version}
* (c) ${new Date().getFullYear()} workflow-vue
* @license ${pkg.license}
*/`
}
const isView = process.argv[4] === 'view'
const getBuildConfig = (): any => {
if (!isView) {
return {
rollupOptions: {
external: [
'vue',
'element-plus'
],
output: {
globals: {
vue: 'Vue'
},
banner: createBanner()
}
},
lib: {
entry: path.resolve(__dirname, './packages/index.ts'),
name: 'workflow',
fileName: 'index',
formats: ['es', 'umd']
},
outDir: path.resolve(__dirname, './dist')
}
}
return {
outDir: '../dist',
}
}
// https://vitejs.dev/config/
export default defineConfig({
base: process.env.NODE_ENV === 'development' ? '/' : '/workflow-vue/',
root: process.env.NODE_ENV !== 'production' ? path.resolve(__dirname, './example') : undefined,
server: {
port: 5555,
host: '0.0.0.0'
},
plugins: [
vue(),
!isView && dts({
include: ['./packages'],
outputDir: './types',
skipDiagnostics: false,
logDiagnostics: true
})
],
build: getBuildConfig()
})