arackaf / customize-cra

Override webpack configurations for create-react-app 2.0
MIT License
2.77k stars 269 forks source link

about less modules #231

Open iamsmartloser opened 4 years ago

iamsmartloser commented 4 years ago

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 commented 4 years ago

Right:xxx.module.less

unsafeFunction commented 4 years ago

@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.

quanglam2807 commented 4 years ago

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

quanglam2807 commented 4 years ago

@unsafeFunction Check out https://github.com/arackaf/customize-cra/issues/226

channprj commented 4 years ago

The same error occurs when I use Ant Design.

channprj commented 4 years ago

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

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