Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix and Speed up Storybook #52209

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions x-pack/legacy/plugins/canvas/.storybook/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { withKnobs } from '@storybook/addon-knobs/react';
import { withInfo } from '@storybook/addon-info';
import { create } from '@storybook/theming';

import { coreMock } from 'src/core/public/mocks';
import { KibanaContextProvider } from '../../../../../src/plugins/kibana_react/public';

// If we're running Storyshots, be sure to register the require context hook.
Expand Down Expand Up @@ -38,9 +37,12 @@ if (process.env.NODE_ENV === 'test') {
}

// Add New Platform Context for any stories that need it
addDecorator(fn => (
<KibanaContextProvider services={coreMock.createStart()}>{fn()}</KibanaContextProvider>
));
const settings = new Map();
settings.set('darkMode', true);
const platform = {
uiSettings: settings,
};
addDecorator(fn => <KibanaContextProvider services={platform}>{fn()}</KibanaContextProvider>);

function loadStories() {
require('./dll_contexts');
Expand Down
7 changes: 7 additions & 0 deletions x-pack/legacy/plugins/canvas/.storybook/dll_contexts.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,10 @@ const uiStyles = require.context(
/[\/\\](?!mixins|variables|_|\.|bootstrap_(light|dark))[^\/\\]+\.less/
);
uiStyles.keys().forEach(key => uiStyles(key));

const json = require.context(
'../shareable_runtime/test/workpads',
false,
/\.json$/
);
json.keys().forEach(key => json(key));
21 changes: 12 additions & 9 deletions x-pack/legacy/plugins/canvas/.storybook/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,18 @@ module.exports = async ({ config }) => {
});

// Parse props data for .tsx files
config.module.rules.push({
test: /\.tsx$/,
// Exclude example files, as we don't display props info for them
exclude: /\.examples.tsx$/,
use: [
// Parse TS comments to create Props tables in the UI
require.resolve('react-docgen-typescript-loader'),
],
});
// This is notoriously slow, and is making Storybook unusable. Disabling for now.
// See: https://github.com/storybookjs/storybook/issues/7998
//
// config.module.rules.push({
// test: /\.tsx$/,
// // Exclude example files, as we don't display props info for them
// exclude: /\.examples.tsx$/,
// use: [
// // Parse TS comments to create Props tables in the UI
// require.resolve('react-docgen-typescript-loader'),
// ],
// });

// Enable SASS, but exclude CSS Modules in Storybook
config.module.rules.push({
Expand Down