-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
110 lines (109 loc) · 2.74 KB
/
vite.config.ts
File metadata and controls
110 lines (109 loc) · 2.74 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
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import dts from 'vite-plugin-dts';
import { defineConfig } from 'vitest/config';
import react from '@vitejs/plugin-react';
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js';
import path from 'path';
import fs from 'fs';
// https://vitejs.dev/config/
export default defineConfig({
test: {
environment: 'jsdom',
globals: true,
},
resolve: {
alias: {
'@assets': path.resolve(__dirname, './src/assets'),
'@components': path.resolve(__dirname, './src/BaseTable/components'),
},
},
build: {
target: 'esnext',
minify: 'terser',
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true,
},
},
lib: {
formats: ['es'],
entry: path.resolve(__dirname, 'src/index.ts'),
name: 'mui-table-react',
fileName: (format) => {
return `mui-table-react.${format}.js`;
},
},
rollupOptions: {
output: {
sourcemapExcludeSources: true,
globals: {
react: 'React',
'react/jsx-runtime': 'jsxRuntime',
},
},
external: [
'react',
'react-dom',
'@mui/material',
'@mui/icons-material',
'@mui/x-date-pickers',
'@emotion/react',
'@emotion/styled',
'@tanstack/react-table',
'material-react-table',
'dayjs',
'lodash',
],
},
},
plugins: [
peerDepsExternal(),
react(),
dts({
rollupTypes: false,
exclude: ['/**/*.stories.tsx', '/**/*.test.tsx'],
insertTypesEntry: true,
outDir: 'dist',
include: ['src/**/*.ts', 'src/**/*.tsx'],
staticImport: true,
compilerOptions: {
baseUrl: '.',
paths: {
'@assets/*': ['src/assets/*'],
'@components/*': ['src/BaseTable/components/*'],
},
},
}),
cssInjectedByJsPlugin(),
{
name: 'add-eslint-ignore-to-dist',
closeBundle() {
const eslintIgnore = `# Ignore all files in built package
*
**/*
`;
const eslintConfig = `// Minimal ESLint config for built package
export default [
{
ignores: ['**/*'],
},
];
`;
const eslintrcJs = `// Legacy ESLint config for built package
module.exports = {
ignorePatterns: ['**/*'],
};
`;
const eslintrcJson = `{
"ignorePatterns": ["**/*"]
}
`;
fs.writeFileSync(path.resolve(__dirname, 'dist/.eslintignore'), eslintIgnore);
fs.writeFileSync(path.resolve(__dirname, 'dist/eslint.config.mjs'), eslintConfig);
fs.writeFileSync(path.resolve(__dirname, 'dist/.eslintrc.js'), eslintrcJs);
fs.writeFileSync(path.resolve(__dirname, 'dist/.eslintrc.json'), eslintrcJson);
},
},
],
});