-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathvite.config.js
More file actions
148 lines (139 loc) · 4.25 KB
/
vite.config.js
File metadata and controls
148 lines (139 loc) · 4.25 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import { globSync } from 'glob';
import { fileURLToPath } from 'node:url';
import dts from 'vite-plugin-dts';
function _getEntries (pathPrefix, globRegex) {
return globSync(globRegex, {
ignore: [
'**/*.story.vue',
'**/*.stories.js',
'**/*.test.js',
'common/storybook_utils.js',
'common/v_html.js',
'common/mixins/keyboard_list_navigation_tester.vue',
'components/plugins/*',
],
maxDepth: 4,
}).reduce((entries, path) => {
const entryName = path
.split('/')
.slice(-2)
.join('/')
.replace(`${pathPrefix}/`, '')
.replace(/\.(vue|js)/, '')
.replaceAll('_', '-');
entries[`${pathPrefix}/${entryName}`] = path;
return entries;
}, {});
}
const commonEntries = _getEntries('common', 'common/*/*.{js,vue}');
const componentEntries = _getEntries('lib', 'components/*/*.{js,vue}');
const directiveEntries = _getEntries('lib', 'directives/*/*.{js,vue}');
const recipeEntries = _getEntries('lib', 'recipes/**/*.{js,vue}');
// https://vitejs.dev/config/
export default defineConfig({
assetsInclude: ['**/*.ftl'],
build: {
target: 'es2020',
sourcemap: true,
minify: true,
rolldownOptions: {
external: [
/^@dialpad/,
/^@tiptap\/(?!vue-3)/,
/^date-fns/,
/^emoji-toolkit/,
/^overlayscrollbars/,
/^prosemirror/,
'regex-combined-emojis',
'deep-equal',
'tippy.js',
'vue',
],
output: {
minifyInternalExports: true,
exports: 'named',
},
treeshake: true,
},
lib: {
entry: {
'dialtone-vue': './index.js',
...commonEntries,
...componentEntries,
...directiveEntries,
...recipeEntries,
// Shared components
'shared/sr_only_close_button': './common/sr_only_close_button.vue',
// Dependencies
'node_modules/@tiptap/vue-3': './node_modules/@tiptap/vue-3/dist/index.js',
// Localization
'localization/index': './localization/index.js',
'localization/en-US': './localization/en-US.ftl?raw',
'localization/zh-CN': './localization/zh-CN.ftl?raw',
'localization/nl-NL': './localization/nl-NL.ftl?raw',
'localization/fr-FR': './localization/fr-FR.ftl?raw',
'localization/de-DE': './localization/de-DE.ftl?raw',
'localization/it-IT': './localization/it-IT.ftl?raw',
'localization/ja-JP': './localization/ja-JP.ftl?raw',
'localization/pt-BR': './localization/pt-BR.ftl?raw',
'localization/ru-RU': './localization/ru-RU.ftl?raw',
'localization/es-LA': './localization/es-LA.ftl?raw',
},
formats: ['es', 'cjs'],
},
},
plugins: [vue(), dts({ vue: true, parallel: true, compilerOptions: { skipLibCheck: true } })],
resolve: {
alias: {
'@': fileURLToPath(new URL('.', import.meta.url)),
},
},
test: {
name: 'dialtone-vue',
globals: true,
environment: 'jsdom',
setupFiles: './tests/setupTests.js',
exclude: ['common/custom-emoji.test.js'],
include: ['./{common,components,directives,recipes}/**/*.test.js'],
coverage: {
provider: 'v8',
reporter: ['text', 'html', 'json'],
reportsDirectory: './coverage',
include: [
'components/**/*.{js,vue}',
'common/**/*.{js,vue}',
'directives/**/*.{js,vue}',
'recipes/**/*.{js,vue}',
],
exclude: [
'**/*.test.js',
'**/*.story.vue',
'**/*.stories.js',
'**/*.config.js',
'**/*.config.cjs',
'**/tests/**',
'**/node_modules/**',
'**/dist/**',
'**/coverage/**',
'common/storybook_utils.js',
'common/v_html.js',
'common/mixins/keyboard_list_navigation_tester.vue',
'components/plugins/*',
'.storybook/**',
'storybook-static/**',
],
clean: true, // clean coverage directory before running tests
skipFull: true, // skip full coverage report
thresholds: { // will fail the build if coverage is below these thresholds
global: {
branches: 80,
functions: 70,
lines: 85,
statements: 85,
},
},
},
},
});