mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-30 07:03:08 +02:00
b8800b8b95
* chore: upgrade Storybook to 8 * ci: restore Storybook workflow * build: createRequire * ci: TurboSnap life extension
65 lines
1.9 KiB
TypeScript
65 lines
1.9 KiB
TypeScript
/*
|
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
import { createRequire } from 'node:module';
|
|
import { dirname, join, resolve } from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
import type { StorybookConfig } from '@storybook/vue3-vite';
|
|
import { type Plugin, mergeConfig } from 'vite';
|
|
import turbosnap from 'vite-plugin-turbosnap';
|
|
|
|
const require = createRequire(import.meta.url);
|
|
const _dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
|
|
const config = {
|
|
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
|
|
addons: [
|
|
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'),
|
|
],
|
|
framework: {
|
|
name: getAbsolutePath('@storybook/vue3-vite') as '@storybook/vue3-vite',
|
|
options: {},
|
|
},
|
|
docs: {
|
|
autodocs: 'tag',
|
|
},
|
|
core: {
|
|
disableTelemetry: true,
|
|
},
|
|
async viteFinal(config) {
|
|
const replacePluginForIsChromatic = config.plugins?.findIndex((plugin) => plugin && (plugin as Partial<Plugin>)?.name === 'replace') ?? -1;
|
|
if (~replacePluginForIsChromatic) {
|
|
config.plugins?.splice(replacePluginForIsChromatic, 1);
|
|
}
|
|
return mergeConfig(config, {
|
|
plugins: [
|
|
{
|
|
// 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',
|
|
},
|
|
],
|
|
build: {
|
|
target: [
|
|
'chrome108',
|
|
'firefox109',
|
|
'safari16',
|
|
],
|
|
},
|
|
});
|
|
},
|
|
} satisfies StorybookConfig;
|
|
export default config;
|
|
|
|
function getAbsolutePath(value: string): string {
|
|
return dirname(require.resolve(join(value, 'package.json')));
|
|
}
|