From 431dffa11675d9c0534370227a59308954688f9d Mon Sep 17 00:00:00 2001 From: Benjy Cui Date: Thu, 14 Apr 2016 10:33:01 +0800 Subject: [PATCH] chore: fix webpack config --- site/entry/index.jsx | 2 +- webpack.config.js | 40 +++++++++++++++++++--------------------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/site/entry/index.jsx b/site/entry/index.jsx index 70b37e1040..cd7b69ab0d 100644 --- a/site/entry/index.jsx +++ b/site/entry/index.jsx @@ -1,7 +1,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; import { Router, Route, IndexRoute, Redirect, hashHistory } from 'react-router'; -import antd from '../../'; +import antd from 'antd'; import * as utils from './utils'; import '../common/lib'; import App from '../component/App'; diff --git a/webpack.config.js b/webpack.config.js index 1093f3dd37..005aecb0e7 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -18,31 +18,29 @@ module.exports = function(webpackConfig) { BrowserDemo: 'site/component/BrowserDemo', }; - if (component !== undefined) { - const babelConfig = require('atool-build/lib/getBabelCommonConfig')(); - babelConfig.plugins.push([ - 'antd', - { - // style: true, - libDir: 'components', - } - ]); + const babelConfig = require('atool-build/lib/getBabelCommonConfig')(); + babelConfig.plugins.push([ + 'antd', + { + // style: true, + libDir: 'components', + } + ]); + const componentRegExp = component && new RegExp(`components/${component.toLowerCase()}/demo/.*\.md`); + webpackConfig.module.loaders.push({ + test: component ? componentRegExp : /\.md$/, + exclude: /node_modules/, + loader: `babel?${JSON.stringify(babelConfig)}!antd-md`, + }); + + if (component !== undefined) { webpackConfig.module.loaders.push({ - test: new RegExp(`components/${component}/demo/.*\.md`), - loader: `babel?${JSON.stringify(babelConfig)}!antd-md`, + test: /\.md$/, + exclude: [/node_modules/, componentRegExp], + loader: `babel!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') {