From 71e4a6fb7ddd11b9aca49bd70ebde410ff3bfec9 Mon Sep 17 00:00:00 2001 From: Benjy Cui Date: Fri, 8 Apr 2016 15:29:04 +0800 Subject: [PATCH] site: support import style respectivly --- components/icon/index.md | 4 +--- package.json | 9 +++++---- scripts/build-common.js | 2 +- scripts/build-demos-list.js | 2 +- site/common/lib.js | 2 +- webpack.config.js | 30 +++++++++++++++++++++++++++++- 6 files changed, 38 insertions(+), 11 deletions(-) diff --git a/components/icon/index.md b/components/icon/index.md index 5850018bde..5dad727654 100644 --- a/components/icon/index.md +++ b/components/icon/index.md @@ -49,7 +49,6 @@ ReactDOM.render(, 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(, mountNode); @@ -58,7 +57,6 @@ ReactDOM.render(, 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(, mountNode); @@ -123,4 +121,4 @@ ul.anticons-list li.copied:after { transform: scale(0.83); font-family: Consolas; } - \ No newline at end of file + diff --git a/package.json b/package.json index 743cfb490b..c7fefad0d2 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/scripts/build-common.js b/scripts/build-common.js index ec870fbe24..6da601a227 100644 --- a/scripts/build-common.js +++ b/scripts/build-common.js @@ -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};'; diff --git a/scripts/build-demos-list.js b/scripts/build-demos-list.js index a381b66492..c0b41d80fd 100644 --- a/scripts/build-demos-list.js +++ b/scripts/build-demos-list.js @@ -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 ],' }); diff --git a/site/common/lib.js b/site/common/lib.js index ad6bb61989..2c58d24f87 100644 --- a/site/common/lib.js +++ b/site/common/lib.js @@ -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'; diff --git a/webpack.config.js b/webpack.config.js index 310f0ef423..7111d69181 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -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') {