import { defineConfig } from "umi";
import HtmlWebpackPlugin from "html-webpack-plugin";
umi自定义打包 文件
export default defineConfig({
npmClient: "npm",
history: { type: "browser" },
hash: false,
outputPath:"static",
chainWebpack(config, { webpack }) {
//---------------------------------js START----------------------------------------//;
config.output.set("filename", "js/[name].js");
config.output.set("chunkFilename", "js/[name].async.js");
//---------------------------------js END----------------------------------------//;
//---------------------------------css END----------------------------------------//;
config.plugins
.get("mini-css-extract-plugin")
.set("args", [{ filename: "css/[name].css" }]);
//---------------------------------css END----------------------------------------//;
// 添加额外插件
config.plugin("html-webpack-plugin").use(HtmlWebpackPlugin, [
{
// title:'rd平台',
template: "./src/index.html", // 源模板文件
filename: "index.html", // 输出文件【注意:这里的根路径是module.exports.output.path】
showErrors: true,
inject: "body",
// 压缩html代码
minify: {
// 移除空格
collapseWhitespace: true,
// 移除注释
removeComments: true,
},
},
]);
return config;
},
headScripts: ["./js/umi.js"],
proxy: {
},
});
umi自定义打包 文件
最新推荐文章于 2024-07-18 16:40:00 发布