sorrycc / roadhog

🐷 Cli tool for creating react apps, configurable version of create-react-app.
2.72k stars 342 forks source link

roadhog 调试信息完善 #564

Open callmez opened 6 years ago

callmez commented 6 years ago

在升级到2.0的时候 出现了以下错误

Module build failed: Error: .plugins[1][1] must be an object, false, or undefined
    at Array.forEach (<anonymous>)
    at Array.forEach (<anonymous>)

虽然报错但是没有详细的错误信息 而且很难定位信息....无从下手

sorrycc commented 6 years ago

配置贴出来看下。

callmez commented 6 years ago

找到问题了是 babelPlugins报错, 用了antd, 和antd-mobile 在1的时候不会报错

{
  "entry": "src/pages/*.js",
  "outputPath": "../public",
  "extraBabelPlugins": [
    "transform-decorators-legacy",
    [
      "import", [
       { "libraryName": "antd", "libraryDirectory": "es", "style": true },
       { "libraryName": "antd-mobile", "libraryDirectory": "lib", "style": true }
     ]
   ]
  ],
  "env": {
    "development": {
      "extraBabelPlugins": [
        "dva-hmr"
      ]
    }
  },
  "ignoreMomentLocale": true,
  "theme": "./src/theme.js",
  "html": {
    "template": "./src/index.ejs"
  },
  "hash": true
}
callmez commented 6 years ago

请问在2里如何同时引用 antd和ant-mobile

sorrycc commented 6 years ago

写两个 ['import', {}],babel@7 不支持数组格式的 option 了。

callmez commented 6 years ago

已解决, 但是有还有个问题就是 cli里显示的错误信息要不是不完全. 要不就会被截断看不到完整的错误信息. 这块的体验还请加强

sorrycc commented 6 years ago

恩,这个 issue 先开着,我找时间完善下。

callmez commented 6 years ago

贴个可以用的配置, 重复使用插件需要 加个 unique name,

{
  "entry": "src/pages/*.js",
  "outputPath": "../public",
  "extraBabelPlugins": [
    "transform-decorators-legacy",
    ["import", { "libraryName": "antd", "libraryDirectory": "es", "style": true }],
    ["import", { "libraryName": "antd-mobile", "libraryDirectory": "lib", "style": true }, "ant-mobile"]
  ],
  "env": {
    "development": {
      "extraBabelPlugins": [
        "dva-hmr"
      ]
    }
  },
  "ignoreMomentLocale": true,
  "theme": "./src/theme.js",
  "html": {
    "template": "./src/index.ejs"
  },
  "hash": true
}