2023-08-28 02:25:31 -07:00
|
|
|
/*
|
2024-02-13 07:59:27 -08:00
|
|
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-08-28 02:25:31 -07:00
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2024-02-14 01:48:25 -08:00
|
|
|
import { createRequire } from 'node:module';
|
|
|
|
import { dirname, join, resolve } from 'node:path';
|
2023-07-09 01:19:07 -07:00
|
|
|
import { fileURLToPath } from 'node:url';
|
2023-04-03 17:38:34 -07:00
|
|
|
import type { StorybookConfig } from '@storybook/vue3-vite';
|
2023-04-13 07:23:11 -07:00
|
|
|
import { type Plugin, mergeConfig } from 'vite';
|
2023-04-07 04:34:23 -07:00
|
|
|
import turbosnap from 'vite-plugin-turbosnap';
|
2023-07-09 01:19:07 -07:00
|
|
|
|
2024-02-14 01:48:25 -08:00
|
|
|
const require = createRequire(import.meta.url);
|
|
|
|
const _dirname = fileURLToPath(new URL('.', import.meta.url));
|
2023-07-09 01:19:07 -07:00
|
|
|
|
2023-04-03 17:38:34 -07:00
|
|
|
const config = {
|
|
|
|
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
|
|
|
|
addons: [
|
2024-02-14 01:48:25 -08: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-03 17:38:34 -07:00
|
|
|
],
|
|
|
|
framework: {
|
2024-02-14 01:48:25 -08:00
|
|
|
name: getAbsolutePath('@storybook/vue3-vite') as '@storybook/vue3-vite',
|
2023-04-03 17:38:34 -07:00
|
|
|
options: {},
|
|
|
|
},
|
|
|
|
docs: {
|
|
|
|
autodocs: 'tag',
|
|
|
|
},
|
|
|
|
core: {
|
|
|
|
disableTelemetry: true,
|
|
|
|
},
|
2023-04-07 04:34:23 -07:00
|
|
|
async viteFinal(config) {
|
2023-04-13 07:23:11 -07:00
|
|
|
const replacePluginForIsChromatic = config.plugins?.findIndex((plugin) => plugin && (plugin as Partial<Plugin>)?.name === 'replace') ?? -1;
|
|
|
|
if (~replacePluginForIsChromatic) {
|
|
|
|
config.plugins?.splice(replacePluginForIsChromatic, 1);
|
|
|
|
}
|
2023-04-03 17:38:34 -07:00
|
|
|
return mergeConfig(config, {
|
2023-04-07 04:34:23 -07:00
|
|
|
plugins: [
|
2024-02-14 01:48:25 -08: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 04:34:23 -07:00
|
|
|
],
|
2023-04-03 17:38:34 -07:00
|
|
|
build: {
|
|
|
|
target: [
|
|
|
|
'chrome108',
|
|
|
|
'firefox109',
|
|
|
|
'safari16',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
} satisfies StorybookConfig;
|
|
|
|
export default config;
|
2024-02-14 01:48:25 -08:00
|
|
|
|
|
|
|
function getAbsolutePath(value: string): string {
|
|
|
|
return dirname(require.resolve(join(value, 'package.json')));
|
|
|
|
}
|