Browse Source

Add entry less file and update document (#1534)

* Add entry less file and update document

* fix pre-publish script
pull/1548/head
afc163 9 years ago
parent
commit
205e76aa73
  1. 9
      README-zh_CN.md
  2. 3
      README.md
  3. 1
      components/style/core/index.less
  4. 1
      components/style/index.less
  5. 1
      docs/react/getting-started.md
  6. 2
      docs/react/introduce.md
  7. 1
      index.js
  8. 2
      package.json
  9. 19
      scripts/prepub.js

9
README-zh_CN.md

@ -31,7 +31,7 @@ ReactDOM.render(<DatePicker />, mountNode);
引入样式:
```jsx
import 'antd/lib/index.css'; // or 'antd/style/index.less'
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)。
@ -43,6 +43,13 @@ import 'antd/lib/index.css'; // or 'antd/style/index.less'
> [IE8 issues](https://github.com/xcatliu/react-ie8)
## TypeScript
```js
///<reference path='./node_modules/antd/type-definitions/antd.d.ts'/>
...
```
## 链接
- [首页](http://ant.design/)

3
README.md

@ -32,7 +32,7 @@ ReactDOM.render(<DatePicker />, mountNode);
Import style:
```jsx
import 'antd/dist/antd.css'; // or 'antd/style/index.less'
import 'antd/dist/antd.css'; // or 'antd/dist/antd.less'
```
### Use modularized antd
@ -49,7 +49,6 @@ babel plugin config:
```jsx
import { DatePicker } from 'antd';
ReactDOM.render(<DatePicker />, mountNode);
```
No need to import style manually.

1
components/style/core/index.less

@ -1,4 +1,3 @@
@import "../themes/default";
@import "../mixins/index";
@import "base";
@import "iconfont";

1
components/style/index.less

@ -1 +1,2 @@
@import "./themes/default";
@import "./core/index.less";

1
docs/react/getting-started.md

@ -147,7 +147,6 @@ Ant Design React 支持所有的现代浏览器和 IE8+。
- [改变主色系](https://github.com/ant-design/antd-init/tree/master/examples/customize-antd-theme)
- [使用本地字体](https://github.com/ant-design/antd-init/tree/master/examples/local-iconfont)
- [构建独立文件](https://github.com/ant-design/antd-init/tree/master/examples/build-antd-standalone)
## 小甜点

2
docs/react/introduce.md

@ -47,7 +47,7 @@ ReactDOM.render(<DatePicker />, mountNode);
引入样式:
```jsx
import 'antd/lib/index.css'; // or 'antd/style/index.less'
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)。

1
index.js

@ -1,3 +1,4 @@
/* eslint no-console:0 */
// this file is not used if use https://github.com/ant-design/babel-plugin-antd
import {

2
package.json

@ -124,7 +124,7 @@
"eslint-fix": "eslint --fix components test site scripts ./*.js --ext '.js,.jsx' && eslint-tinker ./components/*/demo/*.md",
"test": "npm run lint && npm run dist && npm run jest",
"jest": "jest",
"prepub": "node ./scripts/prepub",
"pre-publish":"node ./scripts/prepub",
"pub": "antd-tools run pub",
"beta": "antd-tools run beta",
"authors": "git log --format='%aN <%aE>' | sort -u | grep -v 'users.noreply.github.com' | grep -v 'alibaba-inc.com' | grep -v 'alipay.com' | grep -v 'taobao.com' > AUTHORS.txt"

19
scripts/prepub.js

@ -1,7 +1,20 @@
#!/usr/bin/env node
/* eslint no-console:0, strict:0 */
/* eslint-disable */
'use strict';
console.log('prepub');
// Build a entry less file to dist/antd.less
var fs = require('fs');
var path = require('path');
var componentsPath = path.join(process.cwd(), 'components');
var entryLessContent = `@import "../lib/style/index.less";`;
console.log('Building a entry less file to dist/antd.less');
fs.readdir(componentsPath, function(err, files) {
files.forEach(function(file) {
if (fs.existsSync(path.join(componentsPath, file, 'style', 'index.less'))) {
entryLessContent += `\n@import "../lib/${path.join(file, 'style', 'index.less')}";`
}
});
fs.writeFileSync(path.join(process.cwd(), 'dist', 'antd.less'), entryLessContent);
});

Loading…
Cancel
Save