首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Next.js与Styleguidist和Fela (反应)

Next.js与Styleguidist和Fela (反应)
EN

Stack Overflow用户
提问于 2018-11-23 16:14:11
回答 1查看 960关注 0票数 0

有没有人设法用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的样子:

代码语言:javascript
复制
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在应用程序根目录下?

可能是因为它缺少合适的应用程序根目录?

提前谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-11-28 10:23:38

因此,阿特姆向我指出了一个解决方案,以防有人像我一样卡住,你应该添加一个像这样的包装器:styleguideComponents: { Wrapper: path.join(__dirname, '/FelaProvider') },

所以我的styleguide.config.js看起来就像低音:

代码语言:javascript
复制
    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']
                    }
                }

                }
            ]
        }
        }
    };
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53449936

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档