Skip to content

Commit

Permalink
Fix JS module loader
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed Feb 22, 2019
1 parent 17c2ddd commit bd9d423
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions config/medias.default.php
Expand Up @@ -7,6 +7,9 @@
const UGLY_JS_SRC = HTTP_ROOT.'/dist/global.min.js';
const JS_SRC = HTTP_ROOT.'/dist/global.js';

// "AMD" lite module loader
const JS_MODULE_LOADER = '(function(){var n={};define=function(i,o,c){c.apply(this,o.map(function() {return n}))}})()';

const UGLY_CSS_SRC = HTTP_ROOT.'/dist/global.min.css';
const CSS_SRC = HTTP_ROOT.'/dist/global.css';

Expand Down
4 changes: 2 additions & 2 deletions src/class/Document.php
Expand Up @@ -68,10 +68,9 @@ public function __construct($title, $outputOneFile = false)
);
} else {
$this->head->style(CONFIG\MEDIAS\CSS_SRC);
// "AMD" lite module loader
$this->head->appendChild($this->createElement('script'))
->append(
$this->dom->createCDATASection('(function(){var n={};define=function(i,o,c){c(null,n,n)}})()')
$this->dom->createCDATASection(CONFIG\MEDIAS\JS_MODULE_LOADER)
);
$this->head->script(CONFIG\MEDIAS\JS_SRC);
}
Expand Down Expand Up @@ -105,6 +104,7 @@ public function __destruct()
// Inlining minified JS
$this->getBody()->script()->append(
$this->dom->createCDATASection(
CONFIG\MEDIAS\JS_MODULE_LOADER.';'.
file_get_contents(SRC_DIR . DIRECTORY_SEPARATOR .CONFIG\MEDIAS\UGLY_JS_SRC)
)
);
Expand Down

0 comments on commit bd9d423

Please sign in to comment.