Skip to content

Commit

Permalink
Добавлена проверка на то не является ли js-файл source map
Browse files Browse the repository at this point in the history
  • Loading branch information
vedro-compota committed Jan 22, 2019
1 parent 71afc88 commit a062347
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ Css:
-- Как видно, `SimpleAssetManager` может выводить все зарегистрированные JS и CSS в нужном порядке.
(As you can see `SimpleAssetManager` can print JS or Css like HTML resource tags)

### javascript source maps

Вы можете добавлять source map в массив js.
(You can add source map in `public $js ` array for publishing.)

## Связанные пакеты (Other related packages)

Expand Down
10 changes: 9 additions & 1 deletion src/SimpleAssetManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace ItForFree\SimpleAsset;

use ItForFree\rusphp\File\Path;
use ItForFree\rusphp\PHP\Str\StrCommon;

/**
* Менеджер ассетов (в т.ч. управляет зависимостями)
Expand Down Expand Up @@ -98,13 +99,20 @@ public static function getJsHtml()
$html = '';
foreach (static::$assets as $Asset) {
foreach ($Asset->publishedPaths['js'] as $filePath) {
$html .= "<script type=\"text/javascript\" src=\""
if (!static::isSourceMapFile($filePath)) {
$html .= "<script type=\"text/javascript\" src=\""
. Path::getWithoutDocumentRoot($filePath, true) ."\"></script>\n";
}
}
}
return $html;
}

protected function isSourceMapFile($path)
{
return StrCommon::isEndWith($path, '.map');
}

/**
* Вернёт HTML код для Сss
* @return string
Expand Down

0 comments on commit a062347

Please sign in to comment.