1
0
mirror of https://github.com/flarum/core.git synced 2025-07-24 18:21:33 +02:00

Add extension JS as a file to allow sourcemap detection

Fixes #1538
This commit is contained in:
Toby Zerner
2018-08-18 12:13:17 +09:30
parent 1918b1265f
commit 5f4717da2a

View File

@@ -47,9 +47,18 @@ class ExtensionAssets implements AssetInterface
{ {
if ($this->js) { if ($this->js) {
$sources->addString(function () { $sources->addString(function () {
$name = $this->extension->getId(); return 'var module={}';
});
return 'var module={};'.$this->getContent($this->js).";flarum.extensions['$name']=module.exports"; if (is_callable($this->js)) {
$sources->addString($this->js);
} else {
$sources->addFile($this->js);
}
$sources->addString(function () {
$name = $this->extension->getId();
return "flarum.extensions['$name']=module.exports";
}); });
} }
} }
@@ -65,11 +74,6 @@ class ExtensionAssets implements AssetInterface
} }
} }
private function getContent($asset)
{
return is_callable($asset) ? $asset() : file_get_contents($asset);
}
public function localeJs(SourceCollector $sources, string $locale) public function localeJs(SourceCollector $sources, string $locale)
{ {
} }