site: support import style respectivly

This commit is contained in:
Benjy Cui 2016-04-08 15:29:04 +08:00
parent 2728ea4fa1
commit 71e4a6fb7d
6 changed files with 38 additions and 11 deletions

View File

@ -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);
@ -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);
@ -123,4 +121,4 @@ ul.anticons-list li.copied:after {
transform: scale(0.83);
font-family: Consolas;
}
</style>
</style>

View File

@ -72,7 +72,7 @@
"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",
@ -80,6 +80,7 @@
"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",
@ -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",

View File

@ -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};';

View File

@ -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 ],'
});

View File

@ -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';

View File

@ -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') {