-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite-dist.config.ts
62 lines (58 loc) · 1.47 KB
/
vite-dist.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
import { fileURLToPath, URL } from 'url'
import { defineConfig } from 'vitest/config'
import { type UserConfig } from 'vite'
import { resolve } from 'path'
import vue from '@vitejs/plugin-vue'
import type { RootNode, TemplateChildNode } from '@vue/compiler-core'
function removeDataTestAttrs(node: RootNode | TemplateChildNode) {
if (node.type === 1 /* NodeTypes.ELEMENT */) {
node.props = node.props.filter(prop =>
prop.type === 6 /* NodeTypes.ATTRIBUTE */ ? prop.name !== 'data-cy' : true
)
}
}
export default defineConfig(({ mode }) => {
const base: UserConfig = {
plugins: [
vue({
template: {
compilerOptions: {
nodeTransforms: [removeDataTestAttrs],
},
},
}),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
optimizeDeps: {
exclude: ['ol', 'mapbox-gl'],
force: false,
disabled: true,
},
}
base.build = {
lib: {
entry: resolve(__dirname, 'src/bundle/lib.ts'),
name: 'luxembourg-geoportail',
fileName: 'lux.dist',
formats: ['es'], // outputs only bundle/lux.dist.mjs
},
commonjsOptions: {
exclude: ['ol', 'mapbox-gl'],
},
outDir: 'bundle', // TODO: rename /dist
rollupOptions: {
external: [/^ol\/.*/, /mapbox-gl/],
output: {
globals: {
vue: 'Vue',
},
},
},
minify: mode === 'production',
}
return base
})