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‘] } ] }
原文:https://www.cnblogs.com/lemonzwt/p/11749805.html