///
// Dynamically register all Vue components from `src/components/`
///
const requireComponent = require.context("../src/components", true, /\.vue$/);
requireComponent.keys().forEach(filePath => {
// Get component filename
const fileName = `./${filePath.split("/").pop()}`;
// Get component config
const componentConfig = requireComponent(filePath);
// Get PascalCase name of component
const componentName = upperFirst(
camelCase(
// Strip the leading `./` and extension from the filename
fileName.replace(/^\.\/(.*)\.\w+$/, "$1")
)
);
// Register component globally
Vue.component(
componentName,
// Look for the component options on `.default`, which will
// exist if the component was exported with `export default`,
// otherwise fall back to module's root.
componentConfig.default || componentConfig
);
});
It has been set up this way for convenience:
.storybook/config.js
:Is there a reason to change this? @AaronKow