- Модуль: imopenlines
- Путь к файлу: ~/bitrix/modules/imopenlines/lib/livechatmanager.php
- Класс: BitrixImOpenLinesLiveChatManager
- Вызов: LiveChatManager::compileWidgetAssets
static function compileWidgetAssets()
{
if (!defined('IMOL_WIDGET_GENERATE') || !IMOL_WIDGET_GENERATE)
{
return "";
}
define('UI_DESIGN_TOKENS_SKIP_CUSTOM_EXTENSION', true);
// Note: temporarily remove this constant if you need check on developer version Vue
define('VUEJS_DEBUG_DISABLE', true);
$resources = BitrixMainUIExtension::getResourceList([
'main.core.minimal',
'imopenlines.component.widget',
], [
'skip_extensions' => ['core', 'main.core', 'main.polyfill.core', 'ui.fonts.opensans', 'main.popup', 'im.v2.lib.parser'],
'get_resolved_extension_list' => true,
]);
$scriptContent = "// widget bundle";
foreach ($resources['js'] as $path)
{
$purePath = $path;
$path = Application::getDocumentRoot().$path;
if (!MainIOFile::isFileExists($path))
{
continue;
}
$scriptContent .= "nn// file: ".$purePath."n".MainIOFile::getFileContents($path)."nn";
}
$scriptContent = preg_replace('///#(s?)sourceMappingURL(s?)=(s?)([w.-])+/mi', ' ', $scriptContent);
// change BX.Vue => BX.WidgetVue to use the new features of the library,
// we need to replace default export to another variable
$scriptContent = str_replace(
[
'BX.BitrixVue',
'ui_vue.BitrixVue',
'exports.BitrixVue',
'ui_vue_vuex.Vue',
'ui_vue.Vue',
'exports.Vue',
'BX.Vue',
],
[
'BX.WidgetBitrixVue',
'ui_vue.WidgetBitrixVue',
'exports.WidgetBitrixVue',
'ui_vue_vuex.WidgetVue',
'ui_vue.WidgetVue',
'exports.WidgetVue',
'BX.WidgetVue',
],
$scriptContent
);
MainIOFile::putFileContents(Application::getDocumentRoot().self::WIDGET_PATH_SCRIPT, $scriptContent);
MainIOFile::putFileContents(Application::getDocumentRoot().self::WIDGET_PATH_EXTENTION_LIST, implode("n", $resources['resolved_extension']));
$stylesContent = "/* widget bundle*/";
foreach ($resources['css'] as $path)
{
$purePath = $path;
$path = Application::getDocumentRoot().$path;
if (!MainIOFile::isFileExists($path))
{
continue;
}
$stylesContent .= "nn/* file: ".$purePath." */n".MainIOFile::getFileContents($path)."nn";
}
$stylesContent = preg_replace('//*#(s?)sourceMappingURL(s?)=(s?)([w.-])+(s?*/)/mi', ' ', $stylesContent);
MainIOFile::putFileContents(Application::getDocumentRoot().self::WIDGET_PATH_STYLE, $stylesContent);
return "";
}