Create React App Installation LESS Removal

Execute npm run eject to expose the module

Install npm i less less-loader -D

1 .Open webpack.config.js of react app

const sassRegex = /\.(scss|sass)$/;
const sassModuleRegex = /\.module\. (scss|sass)$/;

//Add

const lessRegex = /\.less$/;
const lessModuleRegex = /\.module\.less$/ ;
2. Add in about 467 lines
{
test: lessRegex,
exclude: sassModuleRegex,
use: getStyleLoaders(
{
importLoaders: 2,
sourceMap: isEnvProduction && shouldUseSourceMap,

},
‘less-loader’
),
// Don’t consider CSS imports dead code even if the

// containing package claims to have no side effects.
// Remove this when webpack adds a warning or an error for this.
// See https://github.com/webpack/webpack/issues/6571
sideEffects: true,
},

// Adds support for CSS Modules, but using SASS
// using the extension .module.scss or .module.sass
{

< div> test: lessModuleRegex,

use: getStyleLoaders(
{
importLoaders: 2,
sourceMap: isEnvProduction && shouldUseSourceMap, < /div>

modules: true,
getLocalIdent: getCSSModuleLocalIdent,
},
‘less-loader’
) ,
},
# Must be above the file-loader
Then you will find npm start will report an error
delete node_modules
reinstall npm instal
npm tsatrt again
Success
Applause

< div> const sassRegex = /\.(scss|sass)$/;

const sassModuleRegex = /\.module\.(scss|sass)$/;

//Add

const lessRegex = /\.less$/;
const lessModuleRegex = /\.module\.less$/;
2. In Add about 467 lines
{
test: lessRegex,
exclude: sassModuleRegex,
use: getStyleLoaders(

{
importLoaders: 2,
sourceMap: isEnvProduction && shouldUseSourceMap,
},
‘less-loader ‘
),
// Don’t consider CSS imports dead code even if the
// containing package claims to have no side effects.

// Remove this when webpack adds a warning or an error for this.
// See https://github.com/webpack/webpack/issu es/6571
sideEffects: true,
},
// Adds support for CSS Modules, but using SASS
// using the extension .module.scss or .module.sass
{
test: lessModuleRegex,
use: getStyleLoaders(
{
importLoaders: 2,
sourceMap: isEnvProduction && shouldUseSourceMap,
modules: true,
getLocalIdent: getCSSModuleLocalIdent,
},
‘less-loader’
),
},
# must be above file-loader< /div>

Then you will find that npm start will report an error
Delete node_modules
Reinstall npm instal
Re-npm tsatrt
Success
Applause

const sassRegex = /\.(scss|sass)$/;

const sassMo duleRegex = /\.module\.(scss|sass)$/;

const lessRegex = /\.less$/;

const lessModuleRegex = /\.module\.less $/;

2. Add in about 467 lines

{
test: lessRegex,
exclude: sassModuleRegex,
use: getStyleLoaders(
{
importLoaders: 2,
sourceMap: isEnvProduction && shouldUseSourceMap,
},
‘less-loader’
),
// Don’t consider CSS imports dead code even if the
// containing package claims to have no side effects.
// Remove this when webpack adds a warning or an error for this.
// See https://github.com/webpack/webpack/issues/6571
sideEffects: true,
},
// Adds support for CSS Modules, but using SASS
// using the extension .module.scss or .module.sass
{
test: lessModuleRegex,
use: getStyleLoaders(

{
importLoaders: 2,
sourceMap: isEnvProduction && shouldUseSourceMap,
modules: true,
getLocalIdent: getCSSModuleLocalIdent,
},
‘less-loader’
),
},
# Required On file-loader
At this time, you will find that npm start will report an error
Delete node_modules
Reinstall npm instal
Then npm tsatrt
Success
applause

{

test: lessRegex,

exclude: sassModuleRegex,

use : getStyleLoaders(

{

importLoaders: 2,

sourceMap: isEnvProduction && shouldUseSourceMap,

},

‘less-loader’

),

// Don’t consider CSS imports dead code even if the

// containing package claims to have no side effects.

// Remove this when webpack adds a warning or an error for this.

// See https://github .com/webpack/webpack/issues/6571

sideEffects: true,

},

// Adds support for CSS Modules, but using SASS

p>

// using the extension .module.scss or .module.sass

{

test: lessModuleRegex,

use: getStyleLoaders(< /p>

{

importLoaders: 2,

sourceMap: isEnvProduction && shouldUseSourceMap,

modules: true,

getLocalIdent : getCSSModuleLocalIdent,

},

‘less-loader’

),

},

# Must be on file-loader

At this time, you will find that npm start will report an error

Delete node_modules

Reinstall npm instal

Re-npm tsatrt

Success

Applause

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 573 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.