webpack.config.js主要配置
{
test:/.css$/,
use:[
'style-loader',
{
loader:'css-loader',
options:{
modules:true
}
},
'sass-loader'
]
}
全部代码
const path = require("path"); //webpack内部方法path组件
const Htmlwebpackplugin = require("html-webpack-plugin");
module.exports = {
mode: "development",
entry: "./src/index.js",
output: {
/* publicPath:'http://baidu.com', */
filename: "main.js",
path: path.resolve(__dirname, "dist")
},
module: {
rules: [{
test: /.(jpg|png)$/,
use: {
loader: 'file-loader',
options: {
name: '[name]_[hash].[ext]',
outputPath: 'images/',
}
}
},
{
test:/.css$/,
use:[
'style-loader',
{
loader:'css-loader',
options:{
modules:true
}
},
'sass-loader'
]
}
]
},
plugins: [
new Htmlwebpackplugin({
template: './src/index.html'
})
]
}
使用css的使用如下图圈圈的写法