Skip to content

Commit

Permalink
Add entry less file and update document (ant-design#1534)
Browse files Browse the repository at this point in the history
* Add entry less file and update document

* fix pre-publish script
  • Loading branch information
afc163 committed Apr 28, 2016
1 parent 36af97c commit 205e76a
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 11 deletions.
9 changes: 8 additions & 1 deletion README-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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/)
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -49,7 +49,6 @@ babel plugin config:

```jsx
import { DatePicker } from 'antd';
ReactDOM.render(<DatePicker />, mountNode);
```

No need to import style manually.
Expand Down
1 change: 0 additions & 1 deletion components/style/core/index.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@import "../themes/default";
@import "../mixins/index";
@import "base";
@import "iconfont";
Expand Down
1 change: 1 addition & 0 deletions components/style/index.less
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
@import "./themes/default";
@import "./core/index.less";
1 change: 0 additions & 1 deletion docs/react/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

## 小甜点

Expand Down
2 changes: 1 addition & 1 deletion docs/react/introduce.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint no-console:0 */
// this file is not used if use https://github.com/ant-design/babel-plugin-antd

import {
Expand All @@ -20,7 +21,7 @@ const antd = {
/* eslint no-console:0 */

if (typeof console !== 'undefined' && console.warn) {
console.warn(`you are using prebuild antd,
console.warn(`you are using prebuild antd,
please use https://github.com/ant-design/babel-plugin-antd to reduce app bundle size.`);
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
19 changes: 16 additions & 3 deletions scripts/prepub.js
Original file line number Diff line number Diff line change
@@ -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);
});

0 comments on commit 205e76a

Please sign in to comment.