Add entry less file and update document (#1534)

* Add entry less file and update document

* fix pre-publish script
This commit is contained in:
afc163 2016-04-28 15:54:18 +08:00
parent 36af97c20b
commit 205e76aa73
9 changed files with 30 additions and 11 deletions

View File

@ -31,7 +31,7 @@ ReactDOM.render(<DatePicker />, mountNode);
引入样式: 引入样式:
```jsx ```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)。 按需加载可通过此写法 `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) > [IE8 issues](https://github.com/xcatliu/react-ie8)
## TypeScript
```js
///<reference path='./node_modules/antd/type-definitions/antd.d.ts'/>
...
```
## 链接 ## 链接
- [首页](http://ant.design/) - [首页](http://ant.design/)

View File

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

View File

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

View File

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

View File

@ -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/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/local-iconfont)
- [构建独立文件](https://github.com/ant-design/antd-init/tree/master/examples/build-antd-standalone)
## 小甜点 ## 小甜点

View File

@ -47,7 +47,7 @@ ReactDOM.render(<DatePicker />, mountNode);
引入样式: 引入样式:
```jsx ```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)。 按需加载可通过此写法 `import DatePicker from 'antd/lib/date-picker'` 或使用插件 [babel-plugin-antd](https://github.com/ant-design/babel-plugin-antd)。

View File

@ -1,3 +1,4 @@
/* 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-antd
import { import {

View File

@ -124,7 +124,7 @@
"eslint-fix": "eslint --fix components test site scripts ./*.js --ext '.js,.jsx' && eslint-tinker ./components/*/demo/*.md", "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", "test": "npm run lint && npm run dist && npm run jest",
"jest": "jest", "jest": "jest",
"prepub": "node ./scripts/prepub", "pre-publish":"node ./scripts/prepub",
"pub": "antd-tools run pub", "pub": "antd-tools run pub",
"beta": "antd-tools run beta", "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" "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"

View File

@ -1,7 +1,20 @@
#!/usr/bin/env node #!/usr/bin/env node
/* eslint no-console:0, strict:0 */ /* eslint-disable */
'use strict'; '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);
});