question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

addLessLoader issue when using less-loader

See original GitHub issue

I’m using react-app-rewired and I’ve recently updated less-loader to the new version (6.0.0). My customize-cra version is 0.9.1.

I’m getting the following error when I run react-app-rewired build:

ValidationError: Invalid options object. Less Loader has been initialized using an options object that does not match the API schema. options has an unknown property ‘source’. These properties are valid: object { lessOptions?, prependData?, appendData?, sourceMap? }

I’ve the config-overrides.js file like this:

const { override, fixBabelImports, addLessLoader } = require("customize-cra");

module.exports = override(
  fixBabelImports("import", {
    libraryName: "antd",
    libraryDirectory: "es",
    style: true
  }),
  addLessLoader({
    lessOptions: {
      javascriptEnabled: true,
      modifyVars: {
        "@primary-color": "#030852", // primary color for all components
      }
    }
  })
);

I added the lessOptions object but it didn’t solve the problem. Could you tell me which is the proper way to set addLessLoader options?

Thanks in advance,

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:17
  • Comments:23

github_iconTop GitHub Comments

3reactions
okankrdgcommented, Feb 25, 2022

I solved fix by installing customize-cra-less-loader

package.json:

"customize-cra": "^1.0.0",
"customize-cra-less-loader": "^2.0.0",
"less": "^4.1.2",
"less-loader": "^10.2.0",

config-override.js:

const { override } = require("customize-cra");
const addLessLoader = require("customize-cra-less-loader");
const path = require("path");

module.exports = override(
  addLessLoader({
    javascriptEnabled: true,
  })
);
3reactions
renhao123commented, Apr 30, 2020

same problem !!! I‘ve rolled back the less and less-loader edit to 2.73 , 4.10. Then the problem resolved. but, it’s really not a good ideal.

Read more comments on GitHub >

github_iconTop Results From Across the Web

less-loader | webpack - JS.ORG
There is a known problem with Less and CSS modules regarding relative file paths in url(...) statements. See this issue for an explanation....
Read more >
less files not getting picked up by less-loader - Stack Overflow
I am using customize-cra with react-app-rewired to add a loader for less files. config-overrides.js file const { override, addLessLoader } = ...
Read more >
How to use the customize-cra.addLessLoader function ... - Snyk
How to use the customize-cra.addLessLoader function in customize-cra. To help you get started, we've selected a few customize-cra examples, based on popular ...
Read more >
customize-cra-less-loader - npm
Add less loader to any create-react-app using customize-cra. Latest version: 2.0.0, last published: a year ago.
Read more >
less-loader - webpack
The blog post is about Sass but it also works for Less. CSS modules gotcha. There is a known problem with Less and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found