2016-05-27 11:48:08 +08:00
|
|
|
const path = require('path');
|
2017-03-29 15:31:01 +08:00
|
|
|
const CSSSplitWebpackPlugin = require('css-split-webpack-plugin').default;
|
2019-08-01 15:28:16 +08:00
|
|
|
const replaceLib = require('@ant-design/tools/lib/replaceLib');
|
2016-05-27 11:48:08 +08:00
|
|
|
|
2017-09-06 09:19:35 +08:00
|
|
|
const isDev = process.env.NODE_ENV === 'development';
|
2017-09-20 14:57:48 +08:00
|
|
|
const usePreact = process.env.REACT_ENV === 'preact';
|
2017-09-06 09:19:35 +08:00
|
|
|
|
2017-11-27 18:28:52 +08:00
|
|
|
function alertBabelConfig(rules) {
|
2018-12-07 16:17:45 +08:00
|
|
|
rules.forEach(rule => {
|
2017-11-27 18:28:52 +08:00
|
|
|
if (rule.loader && rule.loader === 'babel-loader') {
|
2018-01-13 19:11:53 +08:00
|
|
|
if (rule.options.plugins.indexOf(replaceLib) === -1) {
|
|
|
|
rule.options.plugins.push(replaceLib);
|
|
|
|
}
|
2018-11-28 15:00:03 +08:00
|
|
|
// eslint-disable-next-line
|
2018-12-07 16:17:45 +08:00
|
|
|
rule.options.plugins = rule.options.plugins.filter(
|
|
|
|
plugin => !plugin.indexOf || plugin.indexOf('babel-plugin-add-module-exports') === -1,
|
|
|
|
);
|
2019-02-26 16:16:23 +08:00
|
|
|
// Add babel-plugin-add-react-displayname
|
|
|
|
rule.options.plugins.push(require.resolve('babel-plugin-add-react-displayname'));
|
2017-11-27 18:28:52 +08:00
|
|
|
} else if (rule.use) {
|
|
|
|
alertBabelConfig(rule.use);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-05-27 11:48:08 +08:00
|
|
|
module.exports = {
|
2016-05-27 14:31:29 +08:00
|
|
|
port: 8001,
|
2019-04-09 17:29:11 +08:00
|
|
|
hash: true,
|
2017-02-09 16:55:29 +08:00
|
|
|
source: {
|
|
|
|
components: './components',
|
|
|
|
docs: './docs',
|
2018-12-07 16:17:45 +08:00
|
|
|
changelog: ['CHANGELOG.zh-CN.md', 'CHANGELOG.en-US.md'],
|
2017-02-09 16:55:29 +08:00
|
|
|
},
|
2017-01-20 11:47:08 +08:00
|
|
|
theme: './site/theme',
|
|
|
|
htmlTemplate: './site/theme/static/template.html',
|
|
|
|
themeConfig: {
|
|
|
|
categoryOrder: {
|
2017-12-22 17:49:38 +08:00
|
|
|
'Ant Design': 0,
|
2017-12-29 15:24:55 +08:00
|
|
|
原则: 1,
|
2017-12-22 17:49:38 +08:00
|
|
|
Principles: 1,
|
2017-12-29 15:24:55 +08:00
|
|
|
视觉: 2,
|
2017-12-22 17:49:38 +08:00
|
|
|
Visual: 2,
|
2017-12-29 15:24:55 +08:00
|
|
|
模式: 3,
|
2017-12-22 17:49:38 +08:00
|
|
|
Patterns: 3,
|
2018-01-05 23:06:29 +08:00
|
|
|
其他: 6,
|
|
|
|
Other: 6,
|
2017-12-22 17:49:38 +08:00
|
|
|
Components: 100,
|
2019-07-17 19:52:02 +08:00
|
|
|
组件: 100,
|
2016-08-03 17:51:33 +08:00
|
|
|
},
|
2017-01-20 11:47:08 +08:00
|
|
|
typeOrder: {
|
|
|
|
General: 0,
|
|
|
|
Layout: 1,
|
|
|
|
Navigation: 2,
|
|
|
|
'Data Entry': 3,
|
|
|
|
'Data Display': 4,
|
|
|
|
Feedback: 5,
|
2018-11-04 16:20:35 +08:00
|
|
|
Other: 6,
|
2019-05-17 12:05:03 +08:00
|
|
|
Deprecated: 7,
|
2018-11-04 16:20:35 +08:00
|
|
|
通用: 0,
|
|
|
|
布局: 1,
|
|
|
|
导航: 2,
|
|
|
|
数据录入: 3,
|
|
|
|
数据展示: 4,
|
|
|
|
反馈: 5,
|
|
|
|
其他: 6,
|
2019-05-17 12:05:03 +08:00
|
|
|
废弃: 7,
|
2017-01-20 11:47:08 +08:00
|
|
|
},
|
|
|
|
docVersions: {
|
|
|
|
'0.9.x': 'http://09x.ant.design',
|
|
|
|
'0.10.x': 'http://010x.ant.design',
|
|
|
|
'0.11.x': 'http://011x.ant.design',
|
|
|
|
'0.12.x': 'http://012x.ant.design',
|
|
|
|
'1.x': 'http://1x.ant.design',
|
2017-12-04 11:29:39 +08:00
|
|
|
'2.x': 'http://2x.ant.design',
|
2016-08-04 10:52:09 +08:00
|
|
|
},
|
2016-08-03 17:51:33 +08:00
|
|
|
},
|
2016-12-09 13:02:16 +08:00
|
|
|
filePathMapper(filePath) {
|
|
|
|
if (filePath === '/index.html') {
|
|
|
|
return ['/index.html', '/index-cn.html'];
|
|
|
|
}
|
|
|
|
if (filePath.endsWith('/index.html')) {
|
|
|
|
return [filePath, filePath.replace(/\/index\.html$/, '-cn/index.html')];
|
|
|
|
}
|
|
|
|
if (filePath !== '/404.html' && filePath !== '/index-cn.html') {
|
|
|
|
return [filePath, filePath.replace(/\.html$/, '-cn.html')];
|
|
|
|
}
|
|
|
|
return filePath;
|
|
|
|
},
|
2016-06-16 09:59:14 +08:00
|
|
|
doraConfig: {
|
|
|
|
verbose: true,
|
|
|
|
},
|
2018-12-11 17:42:45 +08:00
|
|
|
lessConfig: {
|
|
|
|
javascriptEnabled: true,
|
|
|
|
},
|
2016-05-27 11:48:08 +08:00
|
|
|
webpackConfig(config) {
|
2018-11-28 15:00:03 +08:00
|
|
|
// eslint-disable-next-line
|
2016-05-27 11:48:08 +08:00
|
|
|
config.resolve.alias = {
|
2016-07-24 14:53:09 +08:00
|
|
|
'antd/lib': path.join(process.cwd(), 'components'),
|
2018-05-18 11:34:26 +08:00
|
|
|
'antd/es': path.join(process.cwd(), 'components'),
|
2017-01-20 21:40:53 +08:00
|
|
|
antd: path.join(process.cwd(), 'index'),
|
2016-05-27 11:48:08 +08:00
|
|
|
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
|
|
|
};
|
|
|
|
|
2018-11-28 15:00:03 +08:00
|
|
|
// eslint-disable-next-line
|
2017-06-16 10:56:56 +08:00
|
|
|
config.externals = {
|
|
|
|
'react-router-dom': 'ReactRouterDOM',
|
|
|
|
};
|
2017-09-20 14:57:48 +08:00
|
|
|
|
|
|
|
if (usePreact) {
|
2018-11-28 15:00:03 +08:00
|
|
|
// eslint-disable-next-line
|
2017-09-22 14:00:04 +08:00
|
|
|
config.resolve.alias = Object.assign({}, config.resolve.alias, {
|
2017-09-20 14:57:48 +08:00
|
|
|
react: 'preact-compat',
|
|
|
|
'react-dom': 'preact-compat',
|
|
|
|
'create-react-class': 'preact-compat/lib/create-react-class',
|
|
|
|
'react-router': 'react-router',
|
2017-09-22 14:00:04 +08:00
|
|
|
});
|
2017-09-11 13:55:00 +08:00
|
|
|
}
|
2017-06-16 10:56:56 +08:00
|
|
|
|
2017-11-17 17:23:48 +08:00
|
|
|
if (isDev) {
|
2018-11-28 15:00:03 +08:00
|
|
|
// eslint-disable-next-line
|
2017-11-17 17:23:48 +08:00
|
|
|
config.devtool = 'source-map';
|
|
|
|
}
|
|
|
|
|
2017-11-27 18:28:52 +08:00
|
|
|
alertBabelConfig(config.module.rules);
|
|
|
|
|
2018-12-07 16:17:45 +08:00
|
|
|
config.plugins.push(new CSSSplitWebpackPlugin({ size: 4000 }));
|
2017-03-29 15:31:01 +08:00
|
|
|
|
2016-05-27 11:48:08 +08:00
|
|
|
return config;
|
|
|
|
},
|
2017-09-20 14:57:48 +08:00
|
|
|
|
2019-02-08 10:01:01 +08:00
|
|
|
devServerConfig: {
|
|
|
|
public: process.env.DEV_HOST || 'localhost',
|
|
|
|
disableHostCheck: !!process.env.DEV_HOST,
|
|
|
|
},
|
|
|
|
|
2017-09-06 09:19:35 +08:00
|
|
|
htmlTemplateExtraData: {
|
|
|
|
isDev,
|
2017-09-20 14:57:48 +08:00
|
|
|
usePreact,
|
2017-09-06 09:19:35 +08:00
|
|
|
},
|
2016-05-27 11:48:08 +08:00
|
|
|
};
|