3 回答

TA貢獻1842條經驗 獲得超13個贊
我遇到了同樣的問題,并使用 Business Manager 中的 Merchant Tools > SEO > Dynamic Mapping 模塊解決了它。
在那里,您可以使用如下規則將請求重定向到靜態文件夾:
**/*.bundle.js i s,,,,,/js/{0}.bundle.js
我所有的塊文件都以<module>.bundle模式命名。
在這里您可以找到更多信息:https :
//documentation.b2c.commercecloud.salesforce.com/DOC1/topic/com.demandware.dochelp/content/b2c_commerce/topics/search_engine_optimization/b2c_dynamic_mappings.html
希望這可以幫助。

TA貢獻1936條經驗 獲得超7個贊
我們以不同的方式做到了。這需要兩個步驟
從模板文件中添加一個腳本標記,為靜態路徑創建一個全局變量。就像是
// inside .isml template
<script>
// help webpack know about the path of js scripts -> used for lazy loading
window.__staticPath__ = "${URLUtils.httpsStatic('/')}";
</script>
然后你需要通過__webpack_public_path__在運行時更改來指示 webpack 知道在哪里可以找到塊
// somewhere in your main .js file
// eslint-disable-next-line
__webpack_public_path__ = window.__staticPath__ + 'js/';
可選步驟:
您可能還想從__staticPath__使用替換中刪除代碼版本(至少我們必須這樣做)
__webpack_public_path__ = window.__staticPath__.replace('{YOUR_CODE_VERSION_GOES_HERE}', '') + 'js/';
添加回答
舉報