elado / next-with-less

Next.js + Less CSS Support
MIT License
143 stars 24 forks source link

TypeError: Cannot read properties of undefined (reading 'replace') #30

Closed leotaozeng closed 1 year ago

leotaozeng commented 1 year ago

Versions

next.config.js

const withLess = require("next-with-less");
/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  swcMinify: true,
  lessLoaderOptions: {}
}

module.exports = withLess(nextConfig)

Error Message

TypeError: Cannot read properties of undefined (reading 'replace')
    at addLessToRegExp (/project/sandbox/node_modules/next-with-less/dist/index.js:21:31)
    at addLessToRuleTest (/project/sandbox/node_modules/next-with-less/dist/index.js:77:18)
    at /project/sandbox/node_modules/next-with-less/dist/index.js:87:23
    at Array.forEach (<anonymous>)
    at Object.webpack (/project/sandbox/node_modules/next-with-less/dist/index.js:81:21)
    at Object.getBaseWebpackConfig [as default] (/project/sandbox/node_modules/next/dist/build/webpack-config.js:1413:32)
    at async Promise.all (index 0)
    at async Span.traceAsyncFn (/project/sandbox/node_modules/next/dist/trace/trace.js:79:20)
    at async Span.traceAsyncFn (/project/sandbox/node_modules/next/dist/trace/trace.js:79:20)
    at async HotReloader.start (/project/sandbox/node_modules/next/dist/server/dev/hot-reloader.js:332:30)

image

Examples

nextjs-demo

leotaozeng commented 1 year ago

The error message shows up after installing @next/font with Next.js 13

mayrsascha commented 1 year ago

Having the same issue, makes @next/font unusable unfortunately... I really regret using LESS with Next.js at this point

leotaozeng commented 1 year ago

Having the same issue, makes @next/font unusable unfortunately... I really regret using LESS with Next.js at this point

What's the reason for you to choose less? :)

mayrsascha commented 1 year ago

I chose Ant Design as my component library, which generally works and looks good with my application, but only supports Less

chemicalkosek commented 1 year ago

I chose Ant Design as my component library, which generally works and looks good with my application, but only supports Less

AntD since 5.0 doesn't use less. You can use this guide to migrate: https://ant.design/docs/react/migration-v5