-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathvite.config.ts
85 lines (81 loc) · 2.17 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import path from 'path'
import { BuildOptions, defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue2'
import basicSsl from '@vitejs/plugin-basic-ssl'
import { loadEnv } from 'vite'
import { nodePolyfills } from 'vite-plugin-node-polyfills'
import { viteStaticCopy } from 'vite-plugin-static-copy'
const lib: BuildOptions['lib'] = {
entry: path.resolve(__dirname, './src/main.lib.ts'),
name: 'OCFilePicker',
fileName: 'file-picker',
formats: ['es', 'umd']
}
const wc: BuildOptions['lib'] = {
entry: path.resolve(__dirname, './src/main.wc.ts'),
name: 'OCFilePicker',
fileName: 'file-picker',
formats: ['es', 'umd', 'iife']
}
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
return {
plugins: [
basicSsl(),
vue(),
nodePolyfills({ protocolImports: true }),
viteStaticCopy({
targets: [
{
src: path.resolve(__dirname, './node_modules/owncloud-design-system/dist/system/icons'),
dest: path.resolve(__dirname, mode === 'library' ? './dist/lib/' : './dist/wc/')
},
{
src: path.resolve(__dirname, './node_modules/owncloud-design-system/dist/system/fonts'),
dest: path.resolve(__dirname, mode === 'library' ? './dist/lib/' : './dist/wc/')
}
]
})
],
resolve: {
alias: [
{
find: '~',
replacement: path.resolve(__dirname, './')
},
{
find: 'stream',
replacement: `stream-browserify`
}
]
},
preview: {
https: true,
port: 3000,
host: 'host.docker.internal'
},
build: {
outDir: mode === 'library' ? './dist/lib' : './dist/wc',
lib: mode === 'library' ? lib : wc,
emptyOutDir: false,
minify: false,
rollupOptions: {
external: ['vue'],
output: {
globals: {
vue: 'Vue'
}
}
},
commonjsOptions: {
ignoreTryCatch: (id) => id !== 'stream'
}
},
optimizeDeps: {
include: ['@ownclouders/web-client']
},
define: {
'process.env.NODE_ENV': `"${env.NODE_ENV}"`
}
}
})