chore: fix webpack config

This commit is contained in:
Benjy Cui 2016-04-14 10:33:01 +08:00
parent 63f7a1896c
commit 431dffa116
2 changed files with 20 additions and 22 deletions

View File

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

View File

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