2016-05-27 11:48:08 +08:00
|
|
|
const path = require('path');
|
2016-09-13 14:47:05 +08:00
|
|
|
const CSSSplitWebpackPlugin = require('css-split-webpack-plugin').default;
|
2016-05-27 11:48:08 +08:00
|
|
|
|
2016-08-04 10:52:09 +08:00
|
|
|
function pickerGenerator(module) {
|
|
|
|
const tester = new RegExp(`^docs/${module}`);
|
|
|
|
return (markdownData) => {
|
|
|
|
const filename = markdownData.meta.filename;
|
2016-08-05 19:13:57 +08:00
|
|
|
if (tester.test(filename) &&
|
2016-09-08 16:53:50 +08:00
|
|
|
!/\/demo$/.test(path.dirname(filename))) {
|
2016-08-04 10:52:09 +08:00
|
|
|
return {
|
|
|
|
meta: markdownData.meta,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-05-27 11:48:08 +08:00
|
|
|
module.exports = {
|
2016-05-27 14:31:29 +08:00
|
|
|
port: 8001,
|
2016-05-27 11:48:08 +08:00
|
|
|
source: [
|
|
|
|
'./components',
|
|
|
|
'./docs',
|
2016-09-28 13:43:32 +08:00
|
|
|
'CHANGELOG.zh-CN.md', // TODO: fix it in bisheng
|
|
|
|
'CHANGELOG.en-US.md',
|
2016-05-27 11:48:08 +08:00
|
|
|
],
|
2016-08-03 14:39:55 +08:00
|
|
|
lazyLoad(nodePath, nodeValue) {
|
|
|
|
if (typeof nodeValue === 'string') {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return nodePath.endsWith('/demo');
|
|
|
|
},
|
2016-08-03 17:51:33 +08:00
|
|
|
pick: {
|
|
|
|
components(markdownData) {
|
|
|
|
const filename = markdownData.meta.filename;
|
|
|
|
if (!/^components/.test(filename) ||
|
2016-09-08 16:53:50 +08:00
|
|
|
/\/demo$/.test(path.dirname(filename))) return;
|
2016-08-03 17:51:33 +08:00
|
|
|
|
|
|
|
return {
|
|
|
|
meta: markdownData.meta,
|
|
|
|
};
|
|
|
|
},
|
2016-08-04 10:52:09 +08:00
|
|
|
changelog(markdownData) {
|
2016-09-28 13:43:32 +08:00
|
|
|
if (/CHANGELOG/.test(markdownData.meta.filename)) {
|
2016-08-04 10:52:09 +08:00
|
|
|
return {
|
|
|
|
meta: markdownData.meta,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'docs/pattern': pickerGenerator('pattern'),
|
|
|
|
'docs/practice': pickerGenerator('practice'),
|
|
|
|
'docs/react': pickerGenerator('react'),
|
|
|
|
'docs/resource': pickerGenerator('resource'),
|
|
|
|
'docs/spec': pickerGenerator('spec'),
|
2016-08-03 17:51:33 +08:00
|
|
|
},
|
2016-05-27 11:48:08 +08:00
|
|
|
theme: './site/theme',
|
|
|
|
htmlTemplate: './site/theme/static/template.html',
|
|
|
|
plugins: [
|
|
|
|
'bisheng-plugin-description',
|
2016-07-25 11:30:42 +08:00
|
|
|
'bisheng-plugin-toc?maxDepth=2&keepElem',
|
2016-05-27 11:48:08 +08:00
|
|
|
'bisheng-plugin-react?lang=__react',
|
2016-06-20 14:31:35 +08:00
|
|
|
'bisheng-plugin-antd',
|
2016-05-27 11:48:08 +08:00
|
|
|
],
|
2016-06-16 09:59:14 +08:00
|
|
|
doraConfig: {
|
|
|
|
verbose: true,
|
|
|
|
plugins: ['dora-plugin-upload'],
|
|
|
|
},
|
2016-05-27 11:48:08 +08:00
|
|
|
webpackConfig(config) {
|
|
|
|
config.resolve.alias = {
|
2016-07-24 14:53:09 +08:00
|
|
|
'antd/lib': path.join(process.cwd(), 'components'),
|
2016-05-27 11:48:08 +08:00
|
|
|
antd: process.cwd(),
|
|
|
|
site: path.join(process.cwd(), 'site'),
|
2016-07-27 15:24:43 +08:00
|
|
|
'react-router': 'react-router/umd/ReactRouter',
|
2016-05-27 11:48:08 +08:00
|
|
|
};
|
2016-09-21 16:42:32 +08:00
|
|
|
config.plugins.push(new CSSSplitWebpackPlugin({ preserve: true }));
|
2016-05-27 11:48:08 +08:00
|
|
|
|
2016-09-08 11:09:15 +08:00
|
|
|
config.babel.plugins.push([
|
|
|
|
require.resolve('babel-plugin-transform-runtime'),
|
|
|
|
{
|
|
|
|
polyfill: false,
|
|
|
|
regenerator: true,
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
|
2016-05-27 11:48:08 +08:00
|
|
|
config.babel.plugins.push([
|
2016-09-20 17:17:49 +08:00
|
|
|
require.resolve('babel-plugin-import'),
|
2016-05-27 11:48:08 +08:00
|
|
|
{
|
|
|
|
style: true,
|
|
|
|
libraryName: 'antd',
|
2016-09-20 17:17:49 +08:00
|
|
|
libraryDirectory: 'components',
|
2016-05-27 11:48:08 +08:00
|
|
|
},
|
|
|
|
]);
|
|
|
|
|
|
|
|
return config;
|
|
|
|
},
|
|
|
|
};
|