S
S
stsin2021-10-22 13:11:13
Less
stsin, 2021-10-22 13:11:13

How to include less in create-react-app?

I connect the .less style files of the antd library, in the console there is such an error:

./src/theme.dark.less (./node_modules/css-loader/dist/cjs.js??ref--5-oneOf-8-1!./node_modules/postcss-loader/src??postcss!./node_modules/resolve-url-loader??ref--5-oneOf-8-3!./node_modules/less-loader/dist/cjs.js??ref--5-oneOf-8-4!./src/theme.dark.less)
TypeError: this.getOptions is not a function


I import the styles as follows: the less file itself:
import './theme.dark.less';

.dark {
    @import '~antd/lib/style/themes/default.less';
    @import '~antd/dist/antd.dark.less';
  
    @body-background: #000220;
    @primary-color: #d5b50b; 
  }


added the following to the webpack config:
{
              test: /\.less$/,
              use: getStyleLoaders(
                {
                  importLoaders: 3,
                  sourceMap: isEnvProduction
                    ? shouldUseSourceMap
                    : isEnvDevelopment,
                },
                'less-loader',
                {
                    lessOptions: {
                      javascriptEnabled: true
                    }
                }
              ),
              sideEffects: true,
            },


How to get rid of the error described above?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question