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.

Support `css-loader@^3.0.0` (+ `addLessLoader`)

See original GitHub issue

As part of the 1.0 release, we need to support css-loader@^3.0.0 which was added to create-react-app in #7876.

Currently we have merged #185 into the next branch (published as customize-cra@next), which should support the new css-loader configuration format, but I’m not familiar enough with how users consume css-loader/less-loader to know how best to support this.

I am looking for help testing customize-cra@next regarding this change and feedback on how addLessLoader is implemented. Specifically, #185 changes the value of localIdentName and does not provide a way to override other parts of the modules object, such as getLocalIdent.

What do we need for this to work well for most users?

cc: @Menci @onlyling @iuvword @kunjiang

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
TennyZhuangcommented, Apr 26, 2020

I can’t use addLessLoader. I have tried this


addLessLoader({

  lessOptions: {

    javascriptEnabled: true,

    modifyVars: { '@primary-color': '#A80000' },

  },

}),

and this


addLessLoader({

  javascriptEnabled: true,

  modifyVars: { '@primary-color': '#A80000' },

}),

But I keep getting error this error


./node_modules/antd/es/button/style/index.less (./node_modules/css-loader/dist/cjs.js??ref--6-oneOf-7-1!./node_modules/postcss-loader/src??postcss!./node_modules/less-loader/dist/cjs.js??ref--6-oneOf-7-3!./node_modules/antd/es/button/style/index.less)

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? }

Searched everywhere but can’t find any solution for this.

use customize-cra@next and lessOption works well.

4reactions
hugobarragoncommented, Feb 6, 2020

Any work around for this ?

yes, for now i installed "css-loader": "2.1.1" until the fix is made, and works great

Read more comments on GitHub >

github_iconTop Results From Across the Web

customize-cra-less-loader - npm
Add less loader to any create-react-app using customize-cra . Support with css-loader v3. Only support react-scripts version >= v5.0.0 .
Read more >
How to use the customize-cra.addLessLoader function ... - Snyk
To help you get started, we've selected a few customize-cra.addLessLoader examples, based on popular ways it is used in public projects.
Read more >
How to add less-loader to react-app-rewired config?
it worked with: module.exports = function override(config, env) { config.module.rules[1].oneOf.splice(2, 0, { test: /\.less$/i, ...
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