How to introduce scss into react project

How to introduce scss into react project

First download the dependencies

yarn add sass-loader node-sass

Then in the project path

node_modules/react-scripts/config/webpack.config.js

Open the file and find

insert image description here

Add the code in red line

  {
              test:/\.scss$/,
              loaders: ['style-loader', 'css-loader', 'sass-loader']
            },

You can use scss

Knowledge point expansion:

React pwa configuration

Add the plugin to the webpack configuration file

const WorkboxWebpackPlugin = require('workbox-webpack-plugin')
plugins: [
        new MiniCssExtractPlugin({
            filename: '[name].css'
        }),
        new WorkboxWebpackPlugin.GenerateSW({
            clientsClaim:true,
            skipWaiting:true
        })
    ],

This is the end of this article about how to introduce scss into react projects. For more relevant content about introducing scss into react projects, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • React introduces antd-mobile+postcss to build mobile terminal
  • What are the ways to introduce CSS in React and what are the differences?

<<:  Summary of methods for creating, listing, and deleting Docker containers on Linux

>>:  Tutorial on installing and configuring remote login to MySQL under Ubuntu

Recommend

Software Testing - MySQL (VI: Database Functions)

1.MySQL functions 1. Mathematical functions PI() ...

MySQL uses variables to implement various sorting

Core code -- Below I will demonstrate the impleme...

InnoDB engine redo file maintenance method

If you want to adjust the size and number of Inno...

nginx solves the problem of slow image display and incomplete download

Written in front Recently, a reader told me that ...

JavaScript web page entry-level development detailed explanation

Part 3: ❤Three ways to overlook backend data rece...

JavaScript canvas Tetris game

Tetris is a very classic little game, and I also ...

Sublime / vscode quick implementation of generating HTML code

Table of contents Basic HTML structure Generate s...

How to install openjdk in docker and run the jar package

Download image docker pull openjdk Creating a Dat...

Mysql string interception and obtaining data in the specified string

Preface: I encountered a requirement to extract s...

Summary of Common Terms in CSS (Cascading Style Sheet)

If you use CSS don't forget to write DOCTYPE, ...

Specific example of MySQL multi-table query

1. Use the SELECT clause to query multiple tables...

How to authorize remote connections in MySQL in Linux

Note: Other machines (IP) cannot connect to the M...