mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-11-30 19:19:26 +08:00
36bcaaef85
* chore: use varaible.less * chore: basic primary varaible * chore: Move to variable * chore: align active color * chore: global fix of css variable * chore: primary colors * chore: button danger * chore: btn default error color * chore: button series * chore: More examples * chore: More components * chore: Form demo * chore: form style * fix: Tag & Alert variable * chore: update footer * chore: rm tmp code * chore: transfer * fix: picker column active color * chore: Adjust active bg color * chore: table hover color * chore: all css variables * chore: Global using variables * chore: Test case * chore: Update test logic * chore: back of default less * chore: entry of site use proxy style * chore: update entry * chore: split of variables * refactor: quick dist speed * fix: site use variable version * chore: Update less config * chore: add mv script * chore: Update repalcement script * chore: Add inject variables * chore: Update script * fix: script path * chore: Move to component instead * chore: fix condition * chore: update config * chore: Update in less transform * chore: Modify logic * chore: change to variables * chore: Update name * fix: script name * chore: do inject * revert: back of path * chore: 2 way of generate * bump tools * chore: Add auto replacement script * chore: auto genrate less file * chore: fix test * test: More test case * chore: Update limit config * test: coverage * docs: Update doc
125 lines
3.6 KiB
JavaScript
125 lines
3.6 KiB
JavaScript
const path = require('path');
|
|
const replaceLib = require('@ant-design/tools/lib/replaceLib');
|
|
const getWebpackConfig = require('@ant-design/tools/lib/getWebpackConfig');
|
|
const { ESBuildMinifyPlugin } = require('esbuild-loader');
|
|
const { version } = require('../package.json');
|
|
const themeConfig = require('./themeConfig');
|
|
|
|
const { webpack } = getWebpackConfig;
|
|
|
|
const isDev = process.env.NODE_ENV === 'development';
|
|
|
|
function alertBabelConfig(rules) {
|
|
rules.forEach(rule => {
|
|
if (rule.loader && rule.loader === 'babel-loader') {
|
|
if (rule.options.plugins.indexOf(replaceLib) === -1) {
|
|
rule.options.plugins.push(replaceLib);
|
|
}
|
|
rule.options.plugins = rule.options.plugins.filter(
|
|
plugin => !plugin.indexOf || plugin.indexOf('babel-plugin-add-module-exports') === -1,
|
|
);
|
|
// Add babel-plugin-add-react-displayname
|
|
rule.options.plugins.push(require.resolve('babel-plugin-add-react-displayname'));
|
|
} else if (rule.use) {
|
|
alertBabelConfig(rule.use);
|
|
}
|
|
});
|
|
}
|
|
|
|
module.exports = {
|
|
port: 8001,
|
|
hash: true,
|
|
source: {
|
|
components: './components',
|
|
docs: './docs',
|
|
changelog: ['CHANGELOG.zh-CN.md', 'CHANGELOG.en-US.md'],
|
|
'components/form/v3': ['components/form/v3.zh-CN.md', 'components/form/v3.en-US.md'],
|
|
'docs/resources': ['./docs/resources.zh-CN.md', './docs/resources.en-US.md'],
|
|
},
|
|
theme: './site/theme',
|
|
htmlTemplate: './site/theme/static/template.html',
|
|
themeConfig,
|
|
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;
|
|
},
|
|
doraConfig: {
|
|
verbose: true,
|
|
},
|
|
lessConfig: {
|
|
javascriptEnabled: true,
|
|
modifyVars: {
|
|
'root-entry-name': 'variable',
|
|
},
|
|
},
|
|
webpackConfig(config) {
|
|
config.resolve.alias = {
|
|
'antd/lib': path.join(process.cwd(), 'components'),
|
|
'antd/es': path.join(process.cwd(), 'components'),
|
|
// Change antd from `index.js` to `site/antd.js` to remove deps of root style
|
|
antd: path.join(process.cwd(), 'site', 'antd'),
|
|
site: path.join(process.cwd(), 'site'),
|
|
'react-router': 'react-router/umd/ReactRouter',
|
|
};
|
|
|
|
config.externals = {
|
|
'react-router-dom': 'ReactRouterDOM',
|
|
};
|
|
|
|
if (isDev) {
|
|
config.devtool = 'source-map';
|
|
|
|
// Resolve use react hook fail when yarn link or npm link
|
|
// https://github.com/webpack/webpack/issues/8607#issuecomment-453068938
|
|
config.resolve.alias = {
|
|
...config.resolve.alias,
|
|
'react/jsx-runtime': require.resolve('react/jsx-runtime'),
|
|
react: require.resolve('react'),
|
|
};
|
|
} else if (process.env.ESBUILD) {
|
|
// use esbuild
|
|
config.optimization.minimizer = [
|
|
new ESBuildMinifyPlugin({
|
|
target: 'es2015',
|
|
css: true,
|
|
}),
|
|
];
|
|
}
|
|
|
|
alertBabelConfig(config.module.rules);
|
|
|
|
config.module.rules.push({
|
|
test: /\.mjs$/,
|
|
include: /node_modules/,
|
|
type: 'javascript/auto',
|
|
});
|
|
|
|
config.plugins.push(
|
|
new webpack.DefinePlugin({
|
|
antdReproduceVersion: JSON.stringify(version),
|
|
}),
|
|
);
|
|
|
|
delete config.module.noParse;
|
|
|
|
return config;
|
|
},
|
|
|
|
devServerConfig: {
|
|
public: process.env.DEV_HOST || 'localhost',
|
|
disableHostCheck: !!process.env.DEV_HOST,
|
|
},
|
|
|
|
htmlTemplateExtraData: {
|
|
isDev,
|
|
},
|
|
};
|