- webpack默认不识别less,css,style文件,所以需要引入包
- cnpm install less less-loader --save-dev //引入less
- cnpm install --save-dev style-loader //引入style
- cnpm install --save-dev css-loader //引入css
const path = require("path");
module.exports = {
//入口
entry:"./src/js/index.js",
output:{
path:path.resolve(__dirname,"build"),
filename:"./js/build.js"
},
mode:‘development‘,
//使用webpack打包的配置文件
module: {
rules: [
{
test: /\.less$/i,
use: [
{
loader: ‘style-loader‘,
},
{
loader: ‘css-loader‘,
},
{
loader: ‘less-loader‘,
options: {
lessOptions: {
strictMath: true,
},
},
},
],
},
],
},
}
二.webpack打包less文件