JohnAlbin / storybook-addon-fetch-mock

Adds fetch-mock to Storybook
Other
8 stars 5 forks source link

Error upon installation #16

Closed alexbjorlig closed 7 months ago

alexbjorlig commented 10 months ago

I get this error when I try to use the addon:

[vite] Internal server error: No known conditions for "./preview" specifier in "storybook-addon-fetch-mock" package
JohnAlbin commented 10 months ago

Which version of the add-on are you using? Which version of Storybook?

AlbeRCLife commented 9 months ago

Happening the same. Addon version: 2.0.0-beta.1 Storybook version: 7.6.7

My main.ts looks like:

import type { StorybookConfig } from '@storybook/html-vite';
import { dirname, join } from 'path';

/**
 * 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 dirname(require.resolve(join(value, 'package.json')));
}
const config: StorybookConfig = {
    stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
    addons: [
        getAbsolutePath('@storybook/addon-links'),
        getAbsolutePath('@storybook/addon-essentials'),
        getAbsolutePath('@storybook/addon-interactions'),
        getAbsolutePath('storybook-addon-fetch-mock'),
    ],
    framework: {
        name: getAbsolutePath('@storybook/html-vite'),
        options: {},
    },
    docs: {
        autodocs: 'tag',
    },
};
export default config;
JohnAlbin commented 7 months ago

This should be fixed with the just-released v2.0.0.

Please re-open if you are still experiencing this issue. Thanks!