webpack.config.js中配置
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CleanWebpackPlugin = require("clean-webpack-plugin");
const plugin = [
new HtmlWebpackPlugin({
filename: "admin.html",
template: `src/admin/index.html`,
chunks: ["admin"],
inject: true,
minify: {
removeComments: true,
collapseWhitespace: true
}
}),
new HtmlWebpackPlugin({
filename: "mobile.html",
template: `src/mobile/index.html`,
chunks: ["mobile"],
inject: true,
minify: {
removeComments: true,
collapseWhitespace: true
}
})
];
module.exports = {
// 输入
entry: {
admin: path.resolve(__dirname, `src/admin/index.js`),
mobile: path.resolve(__dirname, `src/mobile/index.js`)
},
// 输出
output: {
filename: `[name].[hash].js`,
path: path.resolve(__dirname, `dist`),
publicPath: ``
},
plugins: [
...plugin,
new CleanWebpackPlugin(["dist"]),
],
module: {
rules: []
},
};
网友评论