我想為單個應用程式創建兩個不同的構建。當我執行 npm run build 時,它會運行 webpack 并生成一個構建,并將該構建注入到 index.html 檔案中。我最理想的做法是告訴 webpack 從 index.js 創建一個構建,并從 index2.js 創建另一個構建。我如何實作這一目標?研究了模塊聯合,但無法弄清楚如何在單個應用程式中執行此操作。
uj5u.com熱心網友回復:
您可以在 webpack.config.js 中進行此設定。
module.exports = {
entry: {
bundle1: "path for index1.js",
bundle2: "path for index2.js"
},
output: {
// `filename` provides a template for naming your bundles (remember to use `[name]`)
filename: '[name].js'
publicPath: 'Path for saving directory'
}};
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/507307.html
標籤:反应 网页包 webpack-5 webpack-module-federation
上一篇:UglifyJsPlugin:Uncaught(inpromise)TypeError:Assignmenttoconstantvariable
下一篇:在mysql中計算布林值
