build(WIP): printDist를 모든 코드에 적용

- 현재 summernote 미작동
This commit is contained in:
2021-12-12 19:26:27 +09:00
parent 865d3c89bb
commit 8a899c9afe
59 changed files with 961 additions and 954 deletions
+25 -21
View File
@@ -139,35 +139,40 @@ class WebUtil
return static::preloadAsset($path, 'script');
}
public static function printDist(string $type, string|array $entryName, bool $isDefer = false){
if(is_string($entryName)){
public static function printDist(string $type, string|array $entryName, bool $isDefer = false)
{
if (is_string($entryName)) {
$entryName = [$entryName];
}
if(is_subclass_of('\\sammo\\VersionGit', '\\sammo\\VersionGitDynamic')){
$version = DB::prefix().'_dynamic';
}
else{
$version = VersionGit::getVersion();
}
$basePath = dirname(__DIR__, 2)."/dist_js/{$version}/{$type}";
$serverBasePath = \phpUri::parse(ServConfig::$serverWebPath)->path;
$serverBasePath .= "/dist_js/{$version}/{$type}";
if ($type == 'gateway') {
$serverBasePath .= "/dist_js/{$type}";
$basePath = dirname(__DIR__, 2) . "/dist_js/{$type}";
} else {
if (!class_exists('\\sammo\\VersionGit') || is_subclass_of('\\sammo\\VersionGit', '\\sammo\\VersionGitDynamic')) {
$version = DB::prefix() . '_dynamic';
} else {
$version = VersionGit::getVersion();
}
$serverBasePath .= "/dist_js/{$version}/{$type}";
$basePath = dirname(__DIR__, 2) . "/dist_js/{$version}/{$type}";
}
$outputs = ["\n"];
foreach(["vendors", "common_ts", ...$entryName] as $moduleName){
foreach(['js', 'css'] as $ext){
$checkPath = $basePath."/{$moduleName}.{$ext}";
foreach (["vendors", "common_ts", ...$entryName] as $moduleName) {
foreach (['js', 'css'] as $ext) {
$checkPath = $basePath . "/{$moduleName}.{$ext}";
if (!file_exists($checkPath)) {
$outputs[] = "<!-- '{$version}/{$type}/{$moduleName}.{$ext}' -->\n";
$outputs[] = "<!-- '{$type}/{$moduleName}.{$ext}' -->\n";
continue;
}
$mtime = filemtime($checkPath);
if($ext == 'css'){
if ($ext == 'css') {
$outputs[] = "<link href='{$serverBasePath}/{$moduleName}.{$ext}?{$mtime}' rel='stylesheet' type='text/css' />\n";
}
else if($ext == 'js'){
} else if ($ext == 'js') {
$typeText = $isDefer ? 'defer' : '';
$outputs[] = "<script src='{$serverBasePath}/{$moduleName}.{$ext}?{$mtime}' {$typeText}></script>\n";
}
@@ -251,13 +256,12 @@ class WebUtil
return $purifier->purify($text);
}
public static function errorBackMsg(string $msg, ?string $target=null): string
public static function errorBackMsg(string $msg, ?string $target = null): string
{
$jmsg = Json::encode($msg);
if(!$target){
if (!$target) {
$moveNext = 'history.go(-1);';
}
else{
} else {
$moveNext = "location.replace('{$target}');";
}