webpack4 css文件處理


1.安裝style-loader和css-loader

npm i css-loader style-loader -D

2創建index.html

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

3.創建index.css

body {
    background-color: blue;
}

4.在index.js中引用index.css

import './idnex.css'

5.配置webpack.config.js文件,使css可以進行import操作

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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM