I had the same issue.
Solutions
When using next-compose-plugins you need to export all plugins alongside their config inside the withPlugin()
functions as follow:
exports.module = withPlugin([[withOptimizedImages, { ... }], [withLess, {
lessLoaderOptions: {
javascriptEnabled: true,
modifyVars: themeVariables, // make your antd custom effective
},
webpack: (config, { isServer }) => {
if (isServer) {
const antStyles = /antd/.*?/style.*?/;
const origExternals = [...config.externals];
config.externals = [
(context, request, callback) => {
if (request.match(antStyles)) return callback();
if (typeof origExternals[0] === 'function') {
origExternals[0](context, request, callback);
} else {
callback();
}
},
...(typeof origExternals[0] === 'function' ? [] : origExternals),
];
config.module.rules.unshift({
test: antStyles,
use: 'null-loader',
});
}
const builtInLoader = config.module.rules.find((rule) => {
if (rule.oneOf) {
return (
rule.oneOf.find((deepRule) => {
return deepRule.test && deepRule.test.toString().includes('/a^/');
}) !== undefined
);
}
return false;
});
if (typeof builtInLoader !== 'undefined') {
config.module.rules.push({
oneOf: [
...builtInLoader.oneOf.filter((rule) => {
return (rule.test && rule.test.toString().includes('/a^/')) !== true;
}),
],
});
}
config.resolve.alias['@'] = path.resolve(__dirname);
return config;
},
}]], nextConfig);
If you still face this issue or another, you can still use the next-plugin-antd-less package, and with next-compose-plugins,
It seems this package has a workaround for this mini-css-extract-plugin
issue.
You need to follow the same structure as the @zeit/next-less
:
module.exports = withPlugins([
[withOptimizedImages],
[
withAntdLess,
{
lessVarsFilePath: "./static/styles/antd.less",
},
],
]);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…