-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.js
62 lines (58 loc) · 1.8 KB
/
main.js
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
/** @type { import('@storybook/preact-vite').StorybookConfig } */
import fsPromise from 'fs/promises';
import { StorybookConfig } from '@storybook/preact-vite';
import path from 'path'
import markdown from '../plugins/markdown_plugin'
const config = {
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
],
framework: {
name: "@storybook/preact-vite",
options: {},
},
docs: {
autodocs: "tag",
},
viteFinal: async (config, { configType }) => {
// Custom esbuild configuration
config.esbuild = {
loader: 'jsx',
include: /src\/.*\.jsx?$/,
exclude: [],
};
// Custom esbuild plugin for loading `.js` files as JSX
if (configType === 'DEVELOPMENT') {
config.optimizeDeps = config.optimizeDeps || {};
config.optimizeDeps.esbuildOptions = {
plugins: [
{
name: 'load-js-files-as-jsx',
setup(build) {
build.onLoad({ filter: /src\/.*\.js$/ }, async (args) => ({
loader: 'jsx',
contents: await fsPromise.readFile(args.path, 'utf8'),
}));
},
},
],
};
};
config.plugins.push(markdown());
return {
...config,
resolve: {
alias: [
{ find: '@hanafi', replacement: path.resolve(__dirname, '../contents/hanafi/') },
{ find: '@components', replacement: path.resolve(__dirname, '../src/components/') },
{ find: '@utils', replacement: path.resolve(__dirname, '../src/utils/') },
{ find: '@al-mabsut/muslimah', replacement: path.resolve(__dirname, '../node_modules/@al-mabsut/muslimah/dist/esm/bundle.js') }
]
},
};
},
};
export default config;