1.打包代碼壓縮
2.自動清理構建腳本
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
plugins: [
new CleanWebpackPlugin(),
]
2.css資源內聯
- 方案1:
{
test: /.less$/,
use: [
{
loader: 'style-loader',
options: {
insertAt: "top", // 樣式插入到<head>中
singleton: true // 將所有style合成一個
}
},
'css-loader',
'less-loader'
]
}
const HTMLInlineCSSWebpackPlugin = require("html-inline-css-webpack-plugin").default;
plugins: [
new HTMLInlineCSSWebpackPlugin()
]