1
0
mirror of https://github.com/flarum/core.git synced 2025-07-23 09:41:26 +02:00
* Replace gulp with webpack and npm scripts for JS compilation
* Set up Travis CI to commit compiled JS
* Restructure `js` directory; only one instance of npm, forum/admin are "submodules"
* Refactor JS initializers into Application subclasses
* Maintain partial compatibility API (importing from absolute paths) for extensions
* Remove minification responsibility from PHP asset compiler
* Restructure `less` directory
This commit is contained in:
Toby Zerner
2018-06-20 13:20:31 +09:30
committed by GitHub
parent 7f68717769
commit c6ebef3631
235 changed files with 9351 additions and 57639 deletions

View File

@@ -21,7 +21,7 @@ class Assets implements ExtenderInterface
protected $appName;
protected $assets = [];
protected $bootstrapper;
protected $js;
public function __construct($appName)
{
@@ -35,9 +35,9 @@ class Assets implements ExtenderInterface
return $this;
}
public function bootstrapper($name)
public function js($path)
{
$this->bootstrapper = $name;
$this->js = $path;
return $this;
}
@@ -46,15 +46,19 @@ class Assets implements ExtenderInterface
{
$container->make(Dispatcher::class)->listen(
Rendering::class,
function (Rendering $event) {
function (Rendering $event) use ($extension) {
if (! $this->matches($event)) {
return;
}
$event->addAssets($this->assets);
if ($this->bootstrapper) {
$event->addBootstrapper($this->bootstrapper);
if ($this->js) {
$event->view->getJs()->addString(function () use ($extension) {
$name = $extension->getId();
return 'var module={};'.file_get_contents($this->js).";flarum.extensions['$name']=module.exports";
});
}
}
);