Repository navigation
Expand file tree
/
Copy pathvite.config.js
More file actions
141 lines (138 loc) · 5.25 KB
/
Copy pathvite.config.js
File metadata and controls
141 lines (138 loc) · 5.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
// / <reference types="@vitest/browser-playwright" />
import path from 'path';
import react from '@vitejs/plugin-react';
import { defineConfig, esmExternalRequirePlugin } from 'vite';
import { fileURLToPath } from 'url';
import { storybookTest } from '@storybook/addon-vitest/vitest-plugin';
import { playwright } from '@vitest/browser-playwright';
import autoprefixer from 'autoprefixer';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
// More info at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon
export default defineConfig({
css: {
devSourcemap: true,
preprocessorOptions: {
scss: {
quietDeps: true,
loadPaths: ["./styles/components/cards",
"./styles/components/infoTooltip",
"./styles/components/pagination",
"./styles/components/quarterPicker",
"./styles/components/table"]
}
},
postcss: {
plugins: [
autoprefixer({}) // add options if needed
]
}
},
build: {
cssCodeSplit: false,
commonjsOptions: { transformMixedEsModules: true },
outDir: path.resolve(__dirname, "./dist"),
rolldownOptions: {
input: "./index.js",
plugins: [
esmExternalRequirePlugin({
external: [/^react(-dom)?(\/.+)?$/]
}),
esmExternalRequirePlugin({
external: [/^lodash(-es)?(\/.+)?$/]
}),
esmExternalRequirePlugin({
external: ["accounting"]
}),
esmExternalRequirePlugin({
external: ["prop-types"]
})
],
external: ['react', 'react-dom', 'lodash-es', 'accounting', 'prop-types'],
output: {
globals: {
react: 'React',
'lodash-es': '_',
'prop-types': 'PropTypes',
accounting: 'accounting',
'react-dom': 'ReactDOM',
}
}
},
lib: {
entry: './index.js',
name: 'data-transparency-ui',
fileName: (format) => `index.${format}.js`,
formats: ['es', 'umd', 'cjs'] // Set your required formats
}
},
optimizeDeps: {
rolldownOptions: {
resolve: {
extensions: ['.js', '.jsx']
},
plugins: [
react({
babel: {
// Add your custom Babel plugins here
plugins: [
'babel-plugin-react-compiler', // Example: For React 19 optimization,
"@babel/plugin-syntax-jsx",
"@babel/plugin-transform-runtime",
"@babel/plugin-transform-object-rest-spread",
"@babel/plugin-transform-class-properties",
"@babel/plugin-transform-optional-chaining",
["@babel/plugin-transform-react-jsx", { pragmaFrag: "React.Fragment" }]
],
presets: ["@babel/preset-react", "@babel/preset-env"],
// Set to true if you want Vite to read your root .babelrc file
babelrc: false,
configFile: false
}
})]
}
},
plugins: [
react({
babel: {
// Add your custom Babel plugins here
plugins: [
'babel-plugin-react-compiler', // Example: For React 19 optimization,
"@babel/plugin-syntax-jsx",
"@babel/plugin-transform-runtime",
"@babel/plugin-transform-object-rest-spread",
"@babel/plugin-transform-class-properties",
"@babel/plugin-transform-optional-chaining",
["@babel/plugin-transform-react-jsx", { pragmaFrag: "React.Fragment" }]
],
presets: ["@babel/preset-react", "@babel/preset-env"],
// Set to true if you want Vite to read your root .babelrc file
babelrc: false,
configFile: false
}
})
],
test: {
projects: [{
extends: true,
plugins: [
// The plugin will run tests for the stories defined in your Storybook config
// See options at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon#storybooktest
storybookTest({
configDir: path.join(__dirname, '.storybook')
})],
test: {
name: 'storybook',
browser: {
enabled: true,
headless: true,
provider: playwright({}),
instances: [{
browser: 'chromium'
}]
},
setupFiles: ['.storybook/vitest.setup.ts']
}
}]
}
});