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

about less modules #231

Open
iamsmartloser opened this issue Mar 28, 2020 · 6 comments
Open

about less modules #231

iamsmartloser opened this issue Mar 28, 2020 · 6 comments

Comments

@iamsmartloser
Copy link

iamsmartloser commented Mar 28, 2020

my code is as follows
config-overrides.js

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

module.exports = override(
  fixBabelImports('import', {
    libraryName: 'antd',
    libraryDirectory: 'es',
    style: true,
  }),
  addLessLoader({
      localIdentName: "[name]__[local]--[hash:base64:5]",
    javascriptEnabled: true,
    modifyVars: { '@primary-color': '#25b864' },
  }),
);

There's no problem when it's used like this
import './index.less';

I want to use a. Less file like this

import styles from './index.less';
import cls from 'classnames';

When I print like this
console.log('styles:',styles)
the result is {}

When I change the .less file to the .module.less file, an error will be reported again

why?

@ghost
Copy link

ghost commented Mar 30, 2020

Right:xxx.module.less

@unsafeFunction
Copy link

@shx996 This is not working in my case. Now I get an error
`ValidationError: Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema.

  • options has an unknown property 'localIdentName'. These properties are valid:
    object { url?, import?, modules?, sourceMap?, importLoaders?, localsConvention?, onlyLocals?, esModule? }
    `

@quanglam2807
Copy link

@unsafeFunction I have the same problem. What should i do?

@quanglam2807
Copy link

@unsafeFunction Check out #226

@channprj
Copy link

The same error occurs when I use Ant Design.

@channprj
Copy link

@iamsmartloser addLessLoader() has been changed, so you should add lessOption key in int. Try like below:

// ...
    addLessLoader({
      lessOptions: {
        javascriptEnabled: true,
        modifyVars: { '@primary-color': '#A80000' },
      },
    }),
// ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants