Skip to content

Instantly share code, notes, and snippets.

@ThaddeusJiang
Created July 31, 2018 12:05
Show Gist options
  • Save ThaddeusJiang/436c2aec8d4747e5cacc0a2deabe2874 to your computer and use it in GitHub Desktop.
Save ThaddeusJiang/436c2aec8d4747e5cacc0a2deabe2874 to your computer and use it in GitHub Desktop.
babel-plugin-import 踩坑

1. style 属性引发的 build error

spin build error

使用 npm 安装 antd 会出现上面问题。 使用 yarn 安装 antd 不会。

对应方法

  1. 修改 .babelrc
"sytle": true 改成 "style": "true"。
  1. 或者直接删掉。依据

no style config

2 个方法都有问题。 大概因为我用了 css modules。还是等官方解决方案吧。 Issue

2. "libraryDirectory": "es" 引发 error

截图:无

对应方法:直接不用这个参数。

实际使用的 .babelrc

{
  "presets": ["env", "react"],
  "plugins": [
    "transform-es2015-modules-commonjs",
    "transform-class-properties",
    "transform-object-rest-spread",
    [
      "import",
      {
        "libraryName": "antd"
      }
    ]
  ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment