Browse Source

docs: rename babel-plugin-antd to babel-plugin-import (#3089)

pull/3099/head
chencheng (云谦) 8 years ago
committed by Benjy Cui
parent
commit
9d9185127c
  1. 2
      README-zh_CN.md
  2. 6
      README.md
  3. 4
      docs/react/getting-started.en-US.md
  4. 4
      docs/react/getting-started.zh-CN.md
  5. 4
      docs/react/introduce.en-US.md
  6. 4
      docs/react/introduce.zh-CN.md
  7. 9
      docs/react/practical-projects.en-US.md
  8. 9
      docs/react/practical-projects.zh-CN.md
  9. 4
      index.js
  10. 2
      package.json
  11. 4
      site/bisheng.config.js

2
README-zh_CN.md

@ -33,7 +33,7 @@ ReactDOM.render(<DatePicker />, mountNode);
import 'antd/dist/antd.css'; // or 'antd/dist/antd.less'
```
按需加载可通过此写法 `import DatePicker from 'antd/lib/date-picker'` 或使用插件 [babel-plugin-antd](https://github.com/ant-design/babel-plugin-antd)。
按需加载可通过此写法 `import DatePicker from 'antd/lib/date-picker'` 或使用插件 [babel-plugin-import](https://github.com/ant-design/babel-plugin-import)。
## 浏览器支持

6
README.md

@ -41,19 +41,19 @@ import 'antd/dist/antd.css'; // or 'antd/dist/antd.less'
### Use modularized antd
- Use [babel-plugin-antd](https://github.com/ant-design/babel-plugin-antd) (Recommended)
- Use [babel-plugin-import](https://github.com/ant-design/babel-plugin-import) (Recommended)
```js
// .babelrc
{
"plugins": [["antd", { style: "css" }]]
"plugins": [["import", { libraryName: "antd", style: "css" }]]
}
```
Then you can import components from antd directly.
```jsx
// import js and css modularly, parsed by babel-plugin-antd
// import js and css modularly, parsed by babel-plugin-import
import { DatePicker } from 'antd';
```

4
docs/react/getting-started.en-US.md

@ -157,13 +157,13 @@ If we import a component like this `import { Button } from 'antd';`, then all th
import Button from 'antd/lib/button';
```
If you use `babel`, we recommend to use [babel-plugin-antd](https://github.com/ant-design/babel-plugin-antd). This plugin will convert the following code to the above form:
If you use `babel`, we recommend to use [babel-plugin-import](https://github.com/ant-design/babel-plugin-import). This plugin will convert the following code to the above form:
```jsx
import { Button } from 'antd';
```
And this plugin can also load styles on demand. See the [usage](https://github.com/ant-design/babel-plugin-antd#usage) for further details.
And this plugin can also load styles on demand. See the [usage](https://github.com/ant-design/babel-plugin-import#usage) for further details.
## Customization

4
docs/react/getting-started.zh-CN.md

@ -153,13 +153,13 @@ Ant Design React 支持所有的现代浏览器和 IE8+。
import Button from 'antd/lib/button';
```
如果你使用 babel,我们推荐使用 [babel-plugin-antd](https://github.com/ant-design/babel-plugin-antd) 来进行按需加载,加入这个插件后。你可以仍然这么写:
如果你使用 babel,我们推荐使用 [babel-plugin-import](https://github.com/ant-design/babel-plugin-import) 来进行按需加载,加入这个插件后。你可以仍然这么写:
```jsx
import { Button } from 'antd';
```
插件会帮你转换成上面的写法。另外此插件配合 [style](https://github.com/ant-design/babel-plugin-antd#usage) 属性可以做到模块样式的按需自动加载。
插件会帮你转换成上面的写法。另外此插件配合 [style](https://github.com/ant-design/babel-plugin-import#usage) 属性可以做到模块样式的按需自动加载。
## 配置案例

4
docs/react/introduce.en-US.md

@ -53,9 +53,9 @@ import 'antd/dist/antd.css'; // or 'antd/dist/antd.less'
You can use:
- `import DatePicker from 'antd/lib/date-picker';`
- `import { DatePicker } from 'antd';` when [babel-plugin-antd](https://github.com/ant-design/babel-plugin-antd) is also used.
- `import { DatePicker } from 'antd';` when [babel-plugin-import](https://github.com/ant-design/babel-plugin-import) is also used.
> babel-plugin-antd supports importing components and styles on demand.
> babel-plugin-import supports importing components and styles on demand.
## Version

4
docs/react/introduce.zh-CN.md

@ -53,9 +53,9 @@ import 'antd/dist/antd.css'; // or 'antd/dist/antd.less'
以下两种方法都可以达到按需加载的目的:
- `import DatePicker from 'antd/lib/date-picker'`
- 配合插件 [babel-plugin-antd](https://github.com/ant-design/babel-plugin-antd) 使用 `import { DatePicker } from 'antd';`
- 配合插件 [babel-plugin-import](https://github.com/ant-design/babel-plugin-import) 使用 `import { DatePicker } from 'antd';`
> babel-plugin-antd 支持 js 和 css 同时按需加载。
> babel-plugin-import 支持 js 和 css 同时按需加载。
## 版本

9
docs/react/practical-projects.en-US.md

@ -49,17 +49,18 @@ Open http://localhost:8989 in your browser, you will see dva welcome page.
## Integrate antd
Install `antd` and `babel-plugin-antd` with npm. `babel-plugin-antd` is used to automatically import scripts and stylesheets from antd. See [repo](https://github.com/ant-design/babel-plugin-antd) 。
Install `antd` and `babel-plugin-import` with npm. `babel-plugin-import` is used to automatically import scripts and stylesheets from antd. See [repo](https://github.com/ant-design/babel-plugin-import) 。
```bash
$ npm install antd babel-plugin-antd --save
$ npm install antd babel-plugin-import --save
```
Edit `webpack.config.js` to integrate `babel-plugin-antd`.
Edit `webpack.config.js` to integrate `babel-plugin-import`.
```diff
+ webpackConfig.babel.plugins.push(['antd', {
+ style: 'css'
+ libraryName: 'antd',
+ style: 'css',
+ }]);
```

9
docs/react/practical-projects.zh-CN.md

@ -49,17 +49,18 @@ webpack: bundle build is now finished.
## 使用 antd
通过 npm 安装 `antd``babel-plugin-antd` 。`babel-plugin-antd` 是用来自动引入 antd 的脚本和样式的,详见 [repo](https://github.com/ant-design/babel-plugin-antd) 。
通过 npm 安装 `antd``babel-plugin-import` 。`babel-plugin-import` 是用来自动引入 antd 的脚本和样式的,详见 [repo](https://github.com/ant-design/babel-plugin-import) 。
```bash
$ npm install antd babel-plugin-antd --save
$ npm install antd babel-plugin-import --save
```
编辑 `webpack.config.js`,使 `babel-plugin-antd` 插件生效。
编辑 `webpack.config.js`,使 `babel-plugin-import` 插件生效。
```diff
+ webpackConfig.babel.plugins.push(['antd', {
+ style: 'css'
+ libraryName: 'antd',
+ style: 'css',
+ }]);
```

4
index.js

@ -1,5 +1,5 @@
/* eslint no-console:0 */
// this file is not used if use https://github.com/ant-design/babel-plugin-antd
// this file is not used if use https://github.com/ant-design/babel-plugin-import
function camelCase(name) {
return name.charAt(0).toUpperCase() +
@ -29,6 +29,6 @@ req.keys().forEach((mod) => {
if (process.env.NODE_ENV !== 'production') {
if (typeof console !== 'undefined' && console.warn) {
console.warn(`You are using prebuilt antd,
please use https://github.com/ant-design/babel-plugin-antd to reduce app bundle size.`);
please use https://github.com/ant-design/babel-plugin-import to reduce app bundle size.`);
}
}

2
package.json

@ -79,7 +79,7 @@
"antd-tools": "^0.11.0",
"babel-eslint": "^6.0.2",
"babel-jest": "^13.2.2",
"babel-plugin-antd": "^0.4.0",
"babel-plugin-import": "^1.0.0",
"babel-plugin-transform-runtime": "~6.15.0",
"bisheng": "^0.12.0",
"bisheng-plugin-antd": "~0.2.0",

4
site/bisheng.config.js

@ -80,11 +80,11 @@ module.exports = {
]);
config.babel.plugins.push([
require.resolve('babel-plugin-antd'),
require.resolve('babel-plugin-import'),
{
style: true,
libraryName: 'antd',
libDir: 'components',
libraryDirectory: 'components',
},
]);

Loading…
Cancel
Save