webpack笔记:
程序员文章站
2022-07-12 19:53:12
...
1、分离less到独立的css
使用less之前还需要安装less插件
npm i less --save-dev
npm i extract-text-webpack-plugin --save-dev
修改在配置文件webpack.config
const webpack = require('webpack')
const path = require('path')
const ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
entry: path.join(__dirname, "src/index.js"),
output: {
path: path.join(__dirname, "/dist"),
filename: "bundle.[name].js"
},
module: {
rules: [{
test: /\.less$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: ['css-loader', 'less-loader']
})
}]
},
plugins: [
new ExtractTextPlugin('/css/style.css')
]
}