首页 > web前端 > js教程 > react中怎么安装sass

react中怎么安装sass

coldplay.xixi
发布: 2020-11-26 16:30:50
原创
4991 人浏览过

react中安装sass的方法:首先安装【sass-loader】和n【ode-sass】依赖;然后打开react的webpack配置,并进行相关修改即可。

react中怎么安装sass

  • 该方法适用于所有品牌电脑

react中安装sass的方法:

 一、安装sass-loader和node-sass依赖

npm install sass-loader node-sass --save-dev
登录后复制

二、打开react的webpack配置

node_modules/react-scripts/config/webpack.config.js
登录后复制

找到module下的rules,oneof数组中,然后找到最后一个配置,修改成如下的样子

            {
              loader: require.resolve('file-loader'),
              // Exclude `js` files to keep "css" loader working as it injects
              // its runtime that would otherwise be processed through "file" loader.
              // Also exclude `html` and `json` extensions so they get processed
              // by webpacks internal loaders.
              exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/],
              options: {
                name: 'static/media/[name].[hash:8].[ext]',
              },
            },
            // ** STOP ** Are you adding a new loader?
            // Make sure to add the new loader(s) before the "file" loader.
          {
            test:/\.scss$/,
            loaders: ['style-loader', 'css-loader', 'sass-loader']
          }
登录后复制

ed1c7be56d044f51d1717c763e6a00f.png

三、这样就可以愉快地使用scss文件了

9dade11274a24871de2e3d06ece54da.png

相关免费学习推荐:javascript(视频)

以上是react中怎么安装sass的详细内容。更多信息请关注PHP中文网其他相关文章!

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
作者最新文章
最新问题
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板