Skip to content

Commit

Permalink
site: support import style respectivly
Browse files Browse the repository at this point in the history
  • Loading branch information
benjycui committed Apr 8, 2016
1 parent 2728ea4 commit 71e4a6f
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 11 deletions.
4 changes: 1 addition & 3 deletions components/icon/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ ReactDOM.render(<IconSet className="icons" icons={icons1} key="icons1" />, mount
### 二. 提示建议性图标

```__react
import IconSet from '../../site/component/IconSet';
const icons2 = ['question', 'question-circle-o', 'question-circle', 'plus', 'plus-circle-o', 'plus-circle', 'pause', 'pause-circle-o', 'pause-circle', 'minus', 'minus-circle-o', 'minus-circle', 'plus-square', 'minus-square', 'info', 'info-circle-o', 'info-circle', 'exclamation', 'exclamation-circle-o', 'exclamation-circle', 'cross', 'cross-circle-o', 'cross-circle', 'check', 'check-circle-o', 'check-circle', 'clock-circle-o', 'clock-circle'];
ReactDOM.render(<IconSet className="icons" icons={icons2} key="icons2" />, mountNode);
Expand All @@ -58,7 +57,6 @@ ReactDOM.render(<IconSet className="icons" icons={icons2} key="icons2" />, mount
### 三. 网站通用图标

```__react
import IconSet from '../../site/component/IconSet';
const icons3 = ['lock', 'unlock', 'android', 'apple', 'area-chart', 'bar-chart', 'bars', 'book', 'calendar', 'cloud', 'cloud-download', 'code', 'copy', 'credit-card', 'delete', 'desktop', 'download', 'edit', 'ellipsis', 'file', 'file-text', 'file-unknown', 'folder', 'folder-open', 'github', 'hdd', 'frown', 'meh', 'inbox', 'laptop', 'appstore-o', 'appstore', 'line-chart', 'link', 'logout', 'mail', 'menu-fold', 'menu-unfold', 'mobile', 'notification', 'paper-clip', 'picture', 'pie-chart', 'poweroff', 'reload', 'search', 'setting', 'share-alt', 'shopping-cart', 'smile', 'tablet', 'tag', 'tags', 'to-top', 'upload', 'user', 'video-camera', 'windows', 'ie', 'chrome', 'home', 'loading', 'smile-circle', 'meh-circle', 'frown-circle', 'tags-o', 'tag-o', 'cloud-upload-o', 'cloud-download-o', 'cloud-upload', 'cloud-o', 'star-o', 'star', 'heart-o', 'heart', 'environment', 'environment-o', 'eye', 'eye-o', 'camera', 'camera-o', 'aliwangwang', 'aliwangwang-o', 'save', 'team', 'solution', 'phone', 'filter', 'exception', 'export', 'customerservice', 'qrcode', 'scan', 'like', 'dislike', 'message', 'pay-circle', 'pay-circle-o', 'calculator'];
ReactDOM.render(<IconSet className="icons" icons={icons3} key="icons3" />, mountNode);
Expand Down Expand Up @@ -123,4 +121,4 @@ ul.anticons-list li.copied:after {
transform: scale(0.83);
font-family: Consolas;
}
</style>
</style>
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,15 @@
"warning": "~2.1.0"
},
"devDependencies": {
"antd-md-loader": "~0.2.0",
"antd-md-loader": "~0.4.0",
"atool-build": "^0.6.5",
"babel-cli": "^6.2.0",
"babel-core": "^6.2.1",
"babel-eslint": "^6.0.2",
"babel-jest": "^6.0.1",
"babel-loader": "^6.2.0",
"babel-plugin-add-module-exports": "^0.1.1",
"babel-plugin-antd": "^0.3.1",
"babel-preset-es2015": "^6.1.18",
"babel-preset-react": "^6.1.18",
"babel-preset-react-hmre": "^1.1.0",
Expand Down Expand Up @@ -111,10 +112,10 @@
"ramda": "^0.19.1",
"rc-scroll-anim": "^0.1.7",
"rc-tween-one": "^0.1.8",
"react": "^15.0.0-rc.2",
"react-addons-test-utils": "^15.0.0-rc.2",
"react": "^15.0.0",
"react-addons-test-utils": "^15.0.0",
"react-copy-to-clipboard": "^4.0.1",
"react-dom": "^15.0.0-rc.2",
"react-dom": "^15.0.0",
"react-github-button": "^0.1.1",
"react-router": "^2.0.0",
"react-stateless-wrapper": "~1.0.2",
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = function buildCommon(dirs, outputFile) {
let content = 'module.exports = {';
mds.forEach((fileName) => {
const requirePath = path.relative(path.dirname(outputFile), fileName);
content += `\n '${fileName}': require('babel!antd-md!${requirePath}'),`;
content += `\n '${fileName}': require('${requirePath}'),`;
});
content += '\n};';

Expand Down
2 changes: 1 addition & 1 deletion scripts/build-demos-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = function buildDemosList(dirs, outputPath) {
content += `\n '${key}': [`;
groupedDemos[key].forEach((fileName) => {
const requirePath = path.relative(path.dirname(outputPath), fileName)
content += `\n require('babel!antd-md?demo!${requirePath}'),`;
content += `\n require('${requirePath}'),`;
});
content += '\n ],'
});
Expand Down
2 changes: 1 addition & 1 deletion site/common/lib.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import '../../style/index.less';
import 'antd/style/index.less';
import './styles/tomorrow.less';
import './styles/common.less';
import './styles/markdown.less';
Expand Down
30 changes: 29 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,42 @@ const webpack = require('atool-build/lib/webpack');

module.exports = function(webpackConfig) {
if (process.env.ANTD === 'WEBSITE') {
const component = process.env.COMPONENT_STYLE;

webpackConfig.entry = {
index: './site/entry/index.jsx',
};
webpackConfig.resolve.root = process.cwd();
webpackConfig.resolve.alias = {
antd: 'index',
antd: process.cwd(),
BrowserDemo: 'site/component/BrowserDemo',
};

if (component !== undefined) {
const babelConfig = require('atool-build/lib/getBabelCommonConfig')();
babelConfig.plugins.push([
'antd',
{
// style: true,
libDir: 'components',
}
]);

webpackConfig.module.loaders.push({
test: new RegExp(`components/${component}/demo/.*\.md`),
loader: `babel?${JSON.stringify(babelConfig)}!antd-md`,
});
}

const exclude = [/node_modules/];
if (component) {
exclude.push(new RegExp(`components/${component}/demo/.*\.md`));
}
webpackConfig.module.loaders.push({
test: /\.md$/,
exclude: exclude,
loader: `babel!antd-md`,
});
}

if (process.env.ANTD === 'PRODUCTION') {
Expand Down

0 comments on commit 71e4a6f

Please sign in to comment.