diff --git a/.gitignore b/.gitignore index cb09545f2f..3d966afc91 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,4 @@ config/base.yaml _site npm-debug.log dist +lib diff --git a/.npmignore b/.npmignore index 039dce92d1..2d856000a4 100644 --- a/.npmignore +++ b/.npmignore @@ -5,3 +5,5 @@ theme static _site site +components +dist \ No newline at end of file diff --git a/README.md b/README.md index 95bfa8afc3..c333a37091 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,21 @@ ![](https://t.alipayobjects.com/images/rmsweb/T11aVgXc4eXXXXXXXX.svg) +## 使用 + +### 静态使用 + +script 直接引用 `dist/antd.js` `dist/antd.css` 后,通过全局变量 antd 使用 + +### npm + +`npm install antd` 后,使用示例 + +```js +require('antd/style/index.less'); +require('antd/lib/datepicker'); +``` + ## 特性 - 丰富实用的 UI 组件。 @@ -47,5 +62,11 @@ $ npm run deploy #### 构建 ```bash -$ webpack +$ npm run build +``` + +#### 发布到 npm + +```bash +$ npm run pub ``` diff --git a/index.js b/index.js index 8551595b48..d2a4120bd9 100644 --- a/index.js +++ b/index.js @@ -17,4 +17,8 @@ var antd = { cssAnimation: require('css-animation') }; -module.exports = window.antd = antd; +module.exports = antd; + +if (typeof window !== undefined) { + window.antd = antd; +} diff --git a/package.json b/package.json index 548a99c527..57fe71d3a1 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "rc-tooltip": "~2.2.3" }, "devDependencies": { + "babel": "~5.6.14", "babel-core": "~5.4.7", "babel-loader": "~5.1.3", "buildbranch": "0.0.3", @@ -47,7 +48,9 @@ "webpack-dev-middleware": "~1.0.11" }, "scripts": { + "babel": "babel components --out-dir lib", "build": "npm run clean && webpack && nico build", + "pub": "npm run babel && npm publish && tnpm sync antd", "start": "npm run clean && nico server --watch", "clean": "rm -rf _site", "deploy": "npm run build && node deploy.js",