build: 빌드 환경 재 설정

- lock에 따라 npm ci로 변경
- webpack build를 서버 내에서 하므로 dev dependency가 거의 없음
- webpack build에서 gateway build를 별도로 작성
This commit is contained in:
2022-03-13 19:47:24 +09:00
parent 5fe9136aa1
commit 91ea0d1c2a
4 changed files with 409 additions and 1553 deletions
+26 -4
View File
@@ -3,6 +3,25 @@ namespace sammo;
set_time_limit(600);
class Json
{
/** @return never */
public static function die($value)
{
if (!headers_sent()) {
header('Expires: Wed, 01 Jan 2014 00:00:00 GMT');
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
}
header('Content-Type: application/json');
die(json_encode($value));
}
}
function tryComposerInstall()
{
$resultPath = 'composer_result.json.log';
@@ -29,7 +48,8 @@ function tryComposerInstall()
if ($result_code != 0) {
Json::die([
'result' => false,
'reason' => $output
'reason' => $output,
'state' => 'composer',
]);
}
@@ -83,7 +103,8 @@ function tryNpmInstall()
if ($result_code != 0) {
Json::die([
'result' => false,
'reason' => $output
'reason' => $output,
'state' => 'npm ci',
]);
}
@@ -105,13 +126,14 @@ function tryNpmInstall()
function genJS()
{
$command = "./node_modules/.bin/webpack build";
$command = sprintf("./node_modules/.bin/webpack build --env target=gateway");
exec(($command), $output, $result_code);
if ($result_code != 0) {
Json::die([
'result' => false,
'reason' => $output
'reason' => $output,
'state' => 'webpack build',
]);
}
}