ant-design/site/bisheng.config.js

94 lines
2.3 KiB
JavaScript
Raw Normal View History

const path = require('path');
2016-09-13 14:47:05 +08:00
const CSSSplitWebpackPlugin = require('css-split-webpack-plugin').default;
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,
};
}
};
}
module.exports = {
2016-05-27 14:31:29 +08:00
port: 8001,
source: [
'./components',
'./docs',
'CHANGELOG.md', // TODO: fix it in bisheng
],
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) {
if (markdownData.meta.filename === 'CHANGELOG.md') {
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
},
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',
'bisheng-plugin-react?lang=__react',
2016-06-20 14:31:35 +08:00
'bisheng-plugin-antd',
],
2016-06-16 09:59:14 +08:00
doraConfig: {
verbose: true,
plugins: ['dora-plugin-upload'],
},
webpackConfig(config) {
config.resolve.alias = {
2016-07-24 14:53:09 +08:00
'antd/lib': path.join(process.cwd(), 'components'),
antd: process.cwd(),
site: path.join(process.cwd(), 'site'),
2016-07-27 15:24:43 +08:00
'react-router': 'react-router/umd/ReactRouter',
};
config.plugins.push(new CSSSplitWebpackPlugin({}));
2016-09-08 11:09:15 +08:00
config.babel.plugins.push([
require.resolve('babel-plugin-transform-runtime'),
{
polyfill: false,
regenerator: true,
},
]);
config.babel.plugins.push([
require.resolve('babel-plugin-import'),
{
style: true,
libraryName: 'antd',
libraryDirectory: 'components',
},
]);
return config;
},
};