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