Как Magento2 генерирует пакет JavaScript?
6
1 answers
Перейдите к Admin -> Stores -> Configuration -> Advanced -> Developer -> Javascript Settings -> Enable Javascript Bundling
установите значение Yes
После приведенной выше конфигурации.
magento\vendor\magento\framework\View\Asset\Config.php
этот флаг называется здесь
/**
* Check whether bundling of JavScript files is on
*
* @return bool
*/
public function isBundlingJsFiles()
{
return (bool)$this->scopeConfig->isSetFlag(
self::XML_PATH_JS_BUNDLING,
ScopeInterface::SCOPE_STORE
);
}
magento\vendor\magento\module-require-js\Block\Html\Head\Config.php
/**
* Include RequireJs configuration as an asset on the page
*
* @return $this
*/
protected function _prepareLayout()
{
if ($this->bundleConfig->isBundlingJsFiles()) { // Check for that FLAG
}
}
Поэтому всякий раз, когда JS модуля или темы вызывается из requirejs-config.js
. Он проверит этот флаг, и если флаг установлен, он объединит (объединит) JS для этого модуля/темы соответственно.
Можете подробнее ознакомиться с файлами ниже
magento\vendor\magento\module-require-js\Model\FileManager.php
public function createBundleJsPool()
{
}
magento\vendor\magento\framework\View\Asset\Bundle\Manager.php
1
Author: Jackson, 2017-02-14 03:00:17