mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-01 03:29:39 +08:00
95 lines
2.4 KiB
JavaScript
95 lines
2.4 KiB
JavaScript
const path = require('path');
|
|
const CSSSplitWebpackPlugin = require('css-split-webpack-plugin').default;
|
|
|
|
function pickerGenerator(module) {
|
|
const tester = new RegExp(`^docs/${module}`);
|
|
return (markdownData) => {
|
|
const filename = markdownData.meta.filename;
|
|
if (tester.test(filename) &&
|
|
!/\/demo$/.test(path.dirname(filename))) {
|
|
return {
|
|
meta: markdownData.meta,
|
|
};
|
|
}
|
|
};
|
|
}
|
|
|
|
module.exports = {
|
|
port: 8001,
|
|
source: [
|
|
'./components',
|
|
'./docs',
|
|
'CHANGELOG.zh-CN.md', // TODO: fix it in bisheng
|
|
'CHANGELOG.en-US.md',
|
|
],
|
|
lazyLoad(nodePath, nodeValue) {
|
|
if (typeof nodeValue === 'string') {
|
|
return true;
|
|
}
|
|
return nodePath.endsWith('/demo');
|
|
},
|
|
pick: {
|
|
components(markdownData) {
|
|
const filename = markdownData.meta.filename;
|
|
if (!/^components/.test(filename) ||
|
|
/\/demo$/.test(path.dirname(filename))) return;
|
|
|
|
return {
|
|
meta: markdownData.meta,
|
|
};
|
|
},
|
|
changelog(markdownData) {
|
|
if (/CHANGELOG/.test(markdownData.meta.filename)) {
|
|
return {
|
|
meta: markdownData.meta,
|
|
};
|
|
}
|
|
},
|
|
'docs/pattern': pickerGenerator('pattern'),
|
|
'docs/practice': pickerGenerator('practice'),
|
|
'docs/react': pickerGenerator('react'),
|
|
'docs/resource': pickerGenerator('resource'),
|
|
'docs/spec': pickerGenerator('spec'),
|
|
},
|
|
theme: './site/theme',
|
|
htmlTemplate: './site/theme/static/template.html',
|
|
plugins: [
|
|
'bisheng-plugin-description',
|
|
'bisheng-plugin-toc?maxDepth=2&keepElem',
|
|
'bisheng-plugin-react?lang=__react',
|
|
'bisheng-plugin-antd',
|
|
],
|
|
doraConfig: {
|
|
verbose: true,
|
|
plugins: ['dora-plugin-upload'],
|
|
},
|
|
webpackConfig(config) {
|
|
config.resolve.alias = {
|
|
'antd/lib': path.join(process.cwd(), 'components'),
|
|
antd: process.cwd(),
|
|
site: path.join(process.cwd(), 'site'),
|
|
'react-router': 'react-router/umd/ReactRouter',
|
|
};
|
|
config.plugins.push(new CSSSplitWebpackPlugin({ preserve: true }));
|
|
|
|
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;
|
|
},
|
|
};
|