Closed luojinghui closed 1 year ago
the same wrong with my project, have you resolve this issue?
Hi guys... Please, provide some details to help you, for example:
Perhaps to help, here I using Next12 and my configs are (I have configured few minutes ago):
my next.config.js
/* eslint-disable */
const withPlugins = require("next-compose-plugins");
const withAntdLess = require("next-plugin-antd-less");
const pluginAntdLess = withAntdLess({
modifyVars: {
hack: `true;@import "${require.resolve(
"./src/style/vendor-theme/less/theme.less"
)}";`,
},
lessVarsFilePath: "./src/style/vendor-theme/less/variables.less",
});
module.exports = withPlugins([[pluginAntdLess]], {
images: {
formats: ["image/avif", "image/webp"],
},
});
and in my _app.tsx
//...
require('../style/vendor-theme/less/theme.less');
// ...
and in ../style/vendor-theme/less/theme.less
we have:
//...
@import "~antd/dist/antd.less";
//...
import React from "react";
import "../styles/index.css";
import { ConfigProvider, Spin } from "antd";
import Layout from "@/components/Layout";
import { useRouter } from "next/router";
import zhCN from "antd/lib/locale/zh_CN";
export default function App({ Component, pageProps }) {
return (
<ConfigProvider locale={zhCN}>
<Layout>
<Component {...pageProps} />
</Layout>
</ConfigProvider>
);
}
config
const withPlugins = require("next-compose-plugins");
const withAntdLess = require("next-plugin-antd-less");
const modifyVars = require("./public/utils/theme");
const path = require("path");
const { configs } = require("./configs");
module.exports = withPlugins([ withAntdLess ], {
lessVarsFilePath: './styles/core/index.less',
modifyVars,
typescript: {
ignoreBuildErrors: true,
},
async rewrites() {
return [
{
source: "/api/:path*",
destination: `${configs.faasApiUrl}/:path*`, // Proxy to Backend
},
];
},
webpack(config, options) {
config.resolve.alias = Object.assign(config.resolve.alias, {
"@": path.resolve("./"),
});
config.module.rules.push({
test: /\.svg$/,
use: ["@svgr/webpack"],
});
return config;
},
});
I change the version of less to 3.x.x,It works.
Init new nextjs project, import antd , then Run
yarn start
is right,but when i runyarn build
, has error:This is my next.config.js: