Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support css-loader@^3.0.0 (+ addLessLoader) #201

Open
with-heart opened this issue Dec 15, 2019 · 11 comments
Open

Support css-loader@^3.0.0 (+ addLessLoader) #201

with-heart opened this issue Dec 15, 2019 · 11 comments
Labels
🧨 breaking change Require a major breaking release to implement. ❓ question Further information is requested ✍️ help wanted Extra attention is needed
Milestone

Comments

@with-heart
Copy link
Collaborator

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

@with-heart with-heart added ✍️ help wanted Extra attention is needed ❓ question Further information is requested 🧨 breaking change Require a major breaking release to implement. labels Dec 15, 2019
@with-heart with-heart added this to the 1.0 milestone Dec 15, 2019
@with-heart with-heart pinned this issue Dec 15, 2019
@Menci
Copy link

Menci commented Dec 15, 2019

How about changing the API to just pass addLessLoader's loaderOptions.cssLoader down to css-loader, merging with the default options?

@edwardwang0302
Copy link
Contributor

edwardwang0302 commented Jan 17, 2020

How about changing the API to just pass addLessLoader's loaderOptions.cssLoader down to css-loader, merging with the default options?

and compatible with the old way pass localIdentName derectly in loaderOptions , and add a second optional param customCssModules which will be passed to css-loader only without define cssLoader/cssModules property in loaderOptions.

Here is my PR

@hugobarragon
Copy link

How about changing the API to just pass addLessLoader's loaderOptions.cssLoader down to css-loader, merging with the default options?

and compatible with the old way pass localIdentName derectly in loaderOptions , and add a second optional param customCssModules which will be passed to css-loader only without define cssLoader/cssModules property in loaderOptions.

Here is my PR

Hi, is it possible to focus on this? is this a good solution, for my projects this is a show stopper i am available to help in any way possible :/

@hellllll0world
Copy link

hellllll0world commented Feb 6, 2020

Any workaround for this ?

@hugobarragon
Copy link

Any work around for this ?

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

@hellllll0world
Copy link

Any work around for this ?

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

thanks for the suggestion, I've tried this and it works great for me too.

@woshilaoda97
Copy link

Any work around for this ?

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

thanks!! it worked

@Ahmdrza
Copy link

Ahmdrza commented 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.

@TennyZhuang
Copy link

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.

@Ahmdrza
Copy link

Ahmdrza commented Apr 26, 2020

@TennyZhuang thanks a lot 👍

@ChnTklc
Copy link

ChnTklc commented Dec 22, 2021

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.

Module build failed (from ./node_modules/postcss-loader/dist/cjs.js):
ValidationError: Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
 - options has an unknown property 'plugins'. These properties are valid:
   object { postcssOptions?, execute?, sourceMap?, implementation? }
"customize-cra": "^1.0.0-alpha.0",
"less": "^4.1.2",
"less-loader": "^10.2.0",
"react-scripts": "^5.0.0",

This solution did not fix my problem any other suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧨 breaking change Require a major breaking release to implement. ❓ question Further information is requested ✍️ help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

9 participants