I want to override the Webpack config by react-app-rewired. But I using Ant design for my project, so I must use Customize-CRA to import Babel plugin, etc. How to using React-app-rewired and Customize-CRA together.
The config-overrides.js for React-app-rewired as below:
module.exports = function override(config, env) {
config.module.rules = config.module.rules.map(rule => {
if (rule.oneOf instanceof Array) {
return {
...rule,
oneOf: [
{
test: /\.(svg|png|jpg|jpeg|gif|bmp|tiff)$/i,
use: [
{
loader: 'file-loader',
options: {
name: '[path][name]-[hash:8].[ext]'
}
}
]
},
...rule.oneOf
]
};
}
return rule;
});
return config;
}
The config-overrides.js for Customize-CRA as below:
const {override, fixBabelImports, addLessLoader, addDecoratorsLegacy, disableEsLint} = require('customize-cra');
module.exports = override(
addDecoratorsLegacy(),
disableEsLint(),
fixBabelImports('import', {
libraryName: 'antd',
libraryDirectory: 'es',
style: true,
}),
addLessLoader({
javascriptEnabled: true,
modifyVars: {'@primary-color': '#a50052'},
}),
);
Thank you.