有没有人设法用Fela和Styleguidist安装next.js?
Styleguidist需要Next.js webpack配置,但是我不能像这里提到的那样链接它:https://react-styleguidist.js.org/docs/webpack.html
我正在使用这个示例应用程序:https://github.com/zeit/next.js/tree/canary/examples/with-fela
下面是我的styleguide.config.js的样子:
module.exports = {
components: 'components/**/*.js',
webpackConfig: {
entry: './pages/_document.js',
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
options: {
presets: ['@babel/react']
}
}
}
]
}
}};
应用程序在Next.js服务器上运行得很好,但是Styleguidist服务器收到了以下错误消息:
错误:没有上下文中的呈现程序,createComponent()无法呈现样式。失去反应-fela在应用程序根目录下?
可能是因为它缺少合适的应用程序根目录?
提前谢谢。
发布于 2018-11-28 10:23:38
因此,阿特姆向我指出了一个解决方案,以防有人像我一样卡住,你应该添加一个像这样的包装器:styleguideComponents: { Wrapper: path.join(__dirname, '/FelaProvider') },
所以我的styleguide.config.js看起来就像低音:
const path = require('path')
module.exports = {
components: 'components/**/*.js',
styleguideComponents: {
Wrapper: path.join(__dirname, '/FelaProvider')
},
webpackConfig: {
entry: 'next/lib/app.js',
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
options: {
presets: ['@babel/react' ],
plugins: ['@babel/plugin-proposal-class-properties']
}
}
}
]
}
}
};https://stackoverflow.com/questions/53449936
复制相似问题