我正在尝试使用 antd 设计向我的下一个 js 项目添加对 less 文件的支持,但无法设置未定义的属性“样式”。我想自定义 antd 主题,但该错误对我来说是一个障碍,任何人有任何想法请帮助我解决这个问题
// next.config.js 文件
const lessToJs = require('less-vars-to-js');
const fs = require('fs');
const path = require('path');
const withPlugins = require('next-compose-plugins');
const withLess = require("@zeit/next-less");
const withCSS = require("@zeit/next-css");
const themeVariable = lessToJs(fs.readFileSync(path.join(__dirname, './styles/antd-custom.less'), 'utf8'));
const nextConfig = {}
module.exports = withPlugins(
[
[
withLess({
lessLoaderOptions: {
javascriptEnabled: true,
modifyVars: themeVariable,
},
webpack: (config, {isServer}) => {
if (isServer) {
const antStyles = /antd\/.*?\/style.*?/;
const origExternals = [...config.externals];
config.externals = [
(context, …Run Code Online (Sandbox Code Playgroud) 我读了很多博客,每个人都提到 Next.js 预取链接,但它对我不起作用。
这是我尝试过的代码:
import Link from 'next/link'
export default function Home() {
return (
<div >
<Link href="/home">
<a>Home</a>
</Link>
<Link href="/About/about">
<a>About</a>
</Link>
</div>
)
}
Run Code Online (Sandbox Code Playgroud)