webpack4 scss文件處理

1.安裝依賴css

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

2.建立index.htmlhtml

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

3.新建index.scssnode

html{
    background-color: red;
}

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

import './css/index.scss'

5.在webpack.config.js中配置處理scssweb

module: {
        rules: [
            {
                test:/\.scss$/,
                use:['style-loader','css-loader','sass-loader']
            }
        ]
    }
相關文章
相關標籤/搜索