-
Notifications
You must be signed in to change notification settings - Fork 143
/
Copy pathmain.ts
74 lines (68 loc) · 2.28 KB
/
main.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
import type { StorybookConfig } from '@storybook/preact-vite';
import { mergeConfig } from 'vite';
import * as path from 'path';
// import eslint from '@rollup/plugin-eslint';
import stylelint from 'vite-plugin-stylelint';
import generateEnvironmentVariables from '../config/environment-variables';
import { resolve } from 'node:path';
const config: StorybookConfig = {
stories: ['../storybook/**/*.stories.@(js|jsx|ts|tsx)'],
addons: [
{
name: '@storybook/addon-essentials',
options: {
docs: false
}
},
{
name: '@storybook/addon-a11y'
}
],
framework: {
name: getAbsolutePath('@storybook/preact-vite'),
options: {}
},
// public added for msw: https://github.com/mswjs/msw-storybook-addon?tab=readme-ov-file#start-storybook
// '../storybook/public'
staticDirs: ['../storybook/assets'],
viteFinal(config) {
return mergeConfig(config, {
define: generateEnvironmentVariables(),
resolve: {
alias: [
{
// this is required for the SCSS modules
find: /^~(.*)$/,
replacement: '$1'
},
{ find: /^styles(.*)$/, replacement: resolve(__dirname, '../src/styles') }
]
},
server: {
watch: {
usePolling: true
}
},
plugins: [
stylelint({ emitErrorAsWarning: true })
// TODO: Enable this once @rollup/plugin-eslint supports ESLINT 9
// {
// ...eslint({
// include: ['./src/**'],
// exclude: ['./src/**/*.json', './src/**/*.scss']
// }),
// enforce: 'pre',
// apply: 'serve'
// }
]
});
}
};
export default config;
/**
* This function is used to resolve the absolute path of a package.
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
*/
function getAbsolutePath(value: string): any {
return path.dirname(require.resolve(path.join(value, 'package.json')));
}