加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Create React App 安装less 报错

发布时间:2020-12-15 09:33:47 所属栏目:百科 来源:网络整理
导读:执行npm run eject 暴露模块 ? 安装 npm i? less less-loader -D ? 1.打开 react app 的 webpack.config.js? const sassRegex = /.(scss|sass)$/; const sassModuleRegex = /.module.(scss|sass)$/; //添加 const lessRegex = /.less$/; const lessModul

执行npm run eject 暴露模块

?

安装 npm i? less less-loader -D

?

1.打开 react app 的 webpack.config.js?

const sassRegex = /.(scss|sass)$/;
const sassModuleRegex = /.module.(scss|sass)$/;
//添加
const lessRegex = /.less$/;
const lessModuleRegex = /.module.less$/;
?
2. 在 大概467 行 添加?
{
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,
modules: true,
getLocalIdent: getCSSModuleLocalIdent,
# 必须在?file-loader 上面
?
?
这时 会发现 npm start 会报错?
?
删除 node_modules?
重新安装 npm instal
?
再npm tsatrt?
成功?
?
?
鼓掌

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读