What is @storybook/core-server?
The @storybook/core-server npm package is part of the Storybook ecosystem, which is a tool for developing UI components in isolation for React, Vue, Angular, and more. It allows developers to serve and manage Storybook instances in a Node.js environment. With this package, you can start a Storybook server, build a static version of Storybook for deployment, and customize various aspects of the Storybook instance.
What are @storybook/core-server's main functionalities?
Starting a Storybook server
This code sample demonstrates how to start a Storybook server on port 6006 using the configuration from the '.storybook' directory.
const { buildDevStandalone } = require('@storybook/core-server');
buildDevStandalone({
port: 6006,
configDir: './.storybook'
}).catch(error => {
console.error(error);
process.exit(1);
});
Building a static Storybook
This code sample shows how to build a static version of Storybook that can be deployed to a web server. The output will be placed in the 'storybook-static' directory.
const { buildStatic } = require('@storybook/core-server');
buildStatic({
staticDir: './public',
configDir: './.storybook',
outputDir: './storybook-static'
}).catch(error => {
console.error(error);
process.exit(1);
});
Customizing Storybook's Webpack configuration
This code sample is typically placed in a '.storybook/main.js' file and demonstrates how to customize Storybook's Webpack configuration using the 'webpackFinal' method.
module.exports = {
stories: ['../src/**/*.stories.js'],
addons: ['@storybook/addon-actions', '@storybook/addon-links'],
webpackFinal: async (config, { configType }) => {
// Modify or return the webpack config.
return config;
}
};
Other packages similar to @storybook/core-server
react-cosmos
React Cosmos is a development tool for creating reusable React components. It allows developers to render components with different props and states, similar to Storybook. However, React Cosmos focuses specifically on React and does not support other frameworks.
docz
Docz leverages MDX to help you document your things with a focus on writing and design. It's similar to Storybook in that it provides a UI for showcasing components, but it uses MDX as the primary format for stories and documentation.