Styleguidist-使用dev webpack配置进行构建

时间:2018-06-22 09:35:12

标签: webpack react-styleguidist

styleguidist server完美运行(非常感谢)

我现在想构建静态的html文件,以便粘贴在github页面中。.

styleguidist build抛出TypeError: Cannot read property 'tapAsync' of undefined,它似乎起源于favicons-webpack-plugin,仅在我的生产Webpack配置中使用。

似乎styleguidist build-p标志传递给了webpack(或者以其他方式导致使用此配置),但我宁愿仅使用dev配置进行构建。

任何人都知道如何或是否可能?

1 个答案:

答案 0 :(得分:0)

不确定您是否仍然遇到此问题,但我遇到了这个问题,使用Create React App和Typescript设置了一个新的Styleguidist项目。...有相同的问题,开发服务器工作正常,但是create-react-app的生产构建设置导致与styleguidist自己的内部事物冲突。

在styleguide.config.js中,附加到我的设置对象中

module.exports = {
  // ...other configgy stuff,
    webpackConfig: require('./node_modules/react-scripts/config/webpack.config.js')(
    'development'
  ),
};

不确定这是否100%正确,但适合我的情况。 根据styleguidist的文档,为create-react-app设置的某些内容可能会破坏该过程

https://react-styleguidist.js.org/docs/webpack.html#reusing-your-projects-webpack-config

我想您也可以这样做。.我是在破解此修复程序后才找到的 https://react-styleguidist.js.org/docs/cookbook#how-to-use-production-or-development-build-of-react

{
  "scripts": {
    "build": "cross-env NODE_ENV=development react-styleguidist build"
  }
}

还没有尝试...猜测我应该先进行RTFM

相关问题