-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
107 lines (103 loc) · 3.04 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/// <reference types="vitest" />
import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts';
import react from '@vitejs/plugin-react';
import copy from 'rollup-plugin-copy';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import svgr from 'vite-plugin-svgr';
import tsconfigPaths from 'vite-tsconfig-paths';
import { transformScssAlias } from './src/build/buildUtils';
import * as packageJson from './package.json';
// const isDev = process.env.NODE_ENV;
const plugins = [svgr(), react(), tsconfigPaths(), dts({ entryRoot: 'src' })];
const scssFilesToTransform = ['src/**/*.scss', '!src/scss/**/*.scss', '!src/design/**', '!src/*.scss'];
// https://vitejs.dev/config/
export default defineConfig({
plugins: plugins,
build: {
target: ['es2019'],
minify: true,
reportCompressedSize: true,
cssCodeSplit: true,
lib: {
// Could also be a dictionary or array of multiple entry points
entry: ['src/index.ts'],
name: 'seldon',
},
rollupOptions: {
input: 'src/index.ts',
output: [
{
dir: 'dist',
format: 'es',
preserveModules: true,
preserveModulesRoot: 'src',
chunkFileNames: '[name].js',
entryFileNames: '[name].js',
},
],
// make sure to externalize deps that shouldn't be bundled
// into your library
external: [...Object.keys(packageJson.peerDependencies)],
plugins: [
copy({
hook: 'writeBundle',
flatten: true,
targets: [
// Sass entrypoint and utils
{
src: ['src/componentStyles.scss', 'src/scss/**/*.scss'],
dest: ['dist/scss'],
transform: (contents) =>
contents
.toString()
.replace(/#scss/g, '.')
.replace(/\.\.\/fonts/g, '@phillips/seldon/dist/fonts'),
},
],
}),
copy({
hook: 'writeBundle',
flatten: false,
targets: [
// Sass components
{
src: scssFilesToTransform,
dest: ['dist/scss'],
transform: transformScssAlias,
},
],
}),
peerDepsExternal(),
],
},
},
test: {
globals: true,
environment: 'jsdom',
include: ['**/*.test.{js,jsx,ts,tsx}'],
exclude: ['node_modules', 'dist', 'build', 'coverage', 'public', 'scripts', 'storybook', '.template/**/*.{ts,tsx}'],
setupFiles: ['./config/vitest/setupTest.ts'],
restoreMocks: true,
coverage: {
include: ['src/**/*.{ts,tsx}'],
exclude: [
'**/*.test.{ts,tsx}',
'**/*.stories.{ts,tsx}',
'**/design/**/*.{ts,tsx}',
'.template/**/*.{ts,tsx}',
'**/index.ts',
'**/types.ts',
], // ignore barrel files
reporter: ['text', 'json', 'html'],
provider: 'v8',
thresholds: {
branches: 90,
lines: 90,
functions: 90,
statements: 90,
},
all: true,
},
},
});