2023-08-28 09:25:31 +00:00
|
|
|
/*
|
2024-02-13 15:59:27 +00:00
|
|
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-08-28 09:25:31 +00:00
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2024-02-14 09:48:25 +00:00
|
|
|
import { createRequire } from 'node:module';
|
|
|
|
import { dirname, join, resolve } from 'node:path';
|
2023-07-09 08:19:07 +00:00
|
|
|
import { fileURLToPath } from 'node:url';
|
2023-04-04 00:38:34 +00:00
|
|
|
import type { StorybookConfig } from '@storybook/vue3-vite';
|
2023-04-13 14:23:11 +00:00
|
|
|
import { type Plugin, mergeConfig } from 'vite';
|
2023-04-07 11:34:23 +00:00
|
|
|
import turbosnap from 'vite-plugin-turbosnap';
|
2023-07-09 08:19:07 +00:00
|
|
|
|
2024-02-14 09:48:25 +00:00
|
|
|
const require = createRequire(import.meta.url);
|
|
|
|
const _dirname = fileURLToPath(new URL('.', import.meta.url));
|
2023-07-09 08:19:07 +00:00
|
|
|
|
2023-04-04 00:38:34 +00:00
|
|
|
const config = {
|
|
|
|
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
|
2024-06-08 09:00:54 +00:00
|
|
|
staticDirs: [{ from: '../assets', to: '/client-assets' }],
|
2023-04-04 00:38:34 +00:00
|
|
|
addons: [
|
2024-02-14 09:48:25 +00:00
|
|
|
getAbsolutePath('@storybook/addon-essentials'),
|
|
|
|
getAbsolutePath('@storybook/addon-interactions'),
|
|
|
|
getAbsolutePath('@storybook/addon-links'),
|
|
|
|
getAbsolutePath('@storybook/addon-storysource'),
|
|
|
|
getAbsolutePath('@storybook/addon-mdx-gfm'),
|
|
|
|
resolve(_dirname, '../node_modules/storybook-addon-misskey-theme'),
|
2023-04-04 00:38:34 +00:00
|
|
|
],
|
|
|
|
framework: {
|
2024-02-14 09:48:25 +00:00
|
|
|
name: getAbsolutePath('@storybook/vue3-vite') as '@storybook/vue3-vite',
|
2023-04-04 00:38:34 +00:00
|
|
|
options: {},
|
|
|
|
},
|
|
|
|
docs: {
|
|
|
|
autodocs: 'tag',
|
|
|
|
},
|
|
|
|
core: {
|
|
|
|
disableTelemetry: true,
|
|
|
|
},
|
2023-04-07 11:34:23 +00:00
|
|
|
async viteFinal(config) {
|
2024-05-01 07:39:16 +00:00
|
|
|
const replacePluginForIsChromatic = config.plugins?.findIndex((plugin: Plugin) => plugin && plugin.name === 'replace') ?? -1;
|
2023-04-13 14:23:11 +00:00
|
|
|
if (~replacePluginForIsChromatic) {
|
|
|
|
config.plugins?.splice(replacePluginForIsChromatic, 1);
|
|
|
|
}
|
2023-04-04 00:38:34 +00:00
|
|
|
return mergeConfig(config, {
|
2023-04-07 11:34:23 +00:00
|
|
|
plugins: [
|
2024-02-14 09:48:25 +00:00
|
|
|
{
|
|
|
|
// XXX: https://github.com/IanVS/vite-plugin-turbosnap/issues/8
|
|
|
|
...(turbosnap as any as typeof turbosnap['default'])({
|
|
|
|
rootDir: config.root ?? process.cwd(),
|
|
|
|
}),
|
|
|
|
name: 'fake-turbosnap',
|
|
|
|
},
|
2023-04-07 11:34:23 +00:00
|
|
|
],
|
2023-04-04 00:38:34 +00:00
|
|
|
build: {
|
|
|
|
target: [
|
|
|
|
'chrome108',
|
|
|
|
'firefox109',
|
|
|
|
'safari16',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
} satisfies StorybookConfig;
|
|
|
|
export default config;
|
2024-02-14 09:48:25 +00:00
|
|
|
|
|
|
|
function getAbsolutePath(value: string): string {
|
|
|
|
return dirname(require.resolve(join(value, 'package.json')));
|
|
|
|
}
|