webpack4 scss文件处理

1.安装依赖

npm i sass-loader node-sass style-loader css-loader -D

2.创建index.html

<html>
<head>
    <meta charset="UTF-8">
    <title>index</title>
</head>
<body>
</body>
</html>

3.新建index.scss

html{
    background-color: red;
}

4.在main.js文件中引用scss

import ‘./css/index.scss‘

5.在webpack.config.js中配置处理scss

module: {
        rules: [
            {
                test:/\.scss$/,
                use:[‘style-loader‘,‘css-loader‘,‘sass-loader‘]
            }
        ]
    }

相关推荐