我尝试使用Nuxt项目中的组件制作故事书。到目前为止,我已经展示了这些组件,但是它们全部都利用了至少一个模块,并且我找不到导入它们的方法。我似乎并没有单独和我的奋斗
(https://forum.vuejs.org/t/nuxt-js-and-storybook/26239,
https://github.com/derekshull/nuxt-starter-kit- v2 / issues / 1),
但我希望有人找到了解决方案。
.storybook / webpack.config.js:
const path = require("@storybook\vue\dist\server\config\defaults\webpack.config.js");
module.exports = {
module: {
rules: [
{
test: /\.scss$/,
loaders: ["style-loader", "css-loader", "sass-loader"],
include: path.resolve(__dirname, "../")
}
]
}
};
.storybook / config.js:
import { configure } from '@storybook/vue';
import Vue from 'vue';
const components = require.context('../components', true, /\.vue$/)
const stories = require.context('../components/stories', true, /.stories.js$/)
components.keys().forEach(filename => {
const [, componentName] = filename.match(/([\w-]+)(.vue)/)
Vue.component(componentName, components(filename).default)
})
function loadStories() {
stories.keys().forEach((filename) => req(filename))
};
configure(loadStories, module);