mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-05 04:11:06 +08:00
split the svelte renderer preview entrypoint into docs & non-docs parts
This commit is contained in:
parent
d77983cd35
commit
ac33fe9541
@ -26,11 +26,9 @@
|
||||
"require": "./dist/index.js",
|
||||
"import": "./dist/index.mjs"
|
||||
},
|
||||
"./preview": {
|
||||
"types": "./dist/config.d.ts",
|
||||
"require": "./dist/config.js",
|
||||
"import": "./dist/config.mjs"
|
||||
},
|
||||
"./preset": "./preset.js",
|
||||
"./dist/preview.mjs": "./dist/preview.mjs",
|
||||
"./dist/preview-docs.mjs": "./dist/preview-docs.mjs",
|
||||
"./package.json": "./package.json",
|
||||
"./templates/HOC.svelte": "./templates/HOC.svelte",
|
||||
"./templates/PreviewRender.svelte": "./templates/PreviewRender.svelte",
|
||||
@ -81,7 +79,9 @@
|
||||
"bundler": {
|
||||
"entries": [
|
||||
"./src/index.ts",
|
||||
"./src/config.ts"
|
||||
"./src/preset.ts",
|
||||
"./src/preview.ts",
|
||||
"./src/preview-docs.ts"
|
||||
],
|
||||
"platform": "browser"
|
||||
},
|
||||
|
1
code/renderers/svelte/preset.js
Normal file
1
code/renderers/svelte/preset.js
Normal file
@ -0,0 +1 @@
|
||||
module.exports = require('./dist/preset');
|
@ -1 +0,0 @@
|
||||
export * from './dist/config.mjs';
|
@ -1,7 +0,0 @@
|
||||
import { parameters as docsParams } from './docs/config';
|
||||
|
||||
export const parameters: {} = { renderer: 'svelte' as const, ...docsParams };
|
||||
export { decorators, argTypesEnhancers } from './docs/config';
|
||||
|
||||
export { render, renderToCanvas } from './render';
|
||||
export { decorateStory as applyDecorators } from './decorators';
|
23
code/renderers/svelte/src/preset.ts
Normal file
23
code/renderers/svelte/src/preset.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import type { LoadedPreset, StorybookConfig } from '@storybook/types';
|
||||
import { join } from 'path';
|
||||
|
||||
const hasDocs = (presetsList: LoadedPreset[]) => {
|
||||
return presetsList.some((preset: string | { name: string }) => {
|
||||
const presetName = typeof preset === 'string' ? preset : preset.name;
|
||||
return presetName.includes('@storybook/addon-docs');
|
||||
});
|
||||
};
|
||||
|
||||
export const previewAnnotations: StorybookConfig['previewAnnotations'] = async (input, options) => {
|
||||
const { presetsList } = options;
|
||||
if (!presetsList) {
|
||||
return input;
|
||||
}
|
||||
const docsInList = hasDocs(presetsList);
|
||||
const result: string[] = [];
|
||||
|
||||
return result
|
||||
.concat(input)
|
||||
.concat([join(__dirname, 'preview.mjs')])
|
||||
.concat(docsInList ? [join(__dirname, 'preview-docs.mjs')] : []);
|
||||
};
|
3
code/renderers/svelte/src/preview-docs.ts
Normal file
3
code/renderers/svelte/src/preview-docs.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export { parameters } from './docs/config';
|
||||
|
||||
export { decorators, argTypesEnhancers } from './docs/config';
|
4
code/renderers/svelte/src/preview.ts
Normal file
4
code/renderers/svelte/src/preview.ts
Normal file
@ -0,0 +1,4 @@
|
||||
export const parameters: {} = { renderer: 'svelte' };
|
||||
|
||||
export { render, renderToCanvas } from './render';
|
||||
export { decorateStory as applyDecorators } from './decorators';
|
Loading…
x
Reference in New Issue
Block a user