build(WIP): 빌드 결과물을 서버 주소에 관계없이 통일
This commit is contained in:
+19
-7
@@ -140,7 +140,7 @@ if (!$v->validate()) {
|
||||
$target = Util::getPost('target');
|
||||
|
||||
$server = basename($request['server']);
|
||||
|
||||
$settingBasePath = __DIR__ . "/{$server}/d_setting/";
|
||||
$allowFullUpdate = in_array('fullUpdate', $session->acl[$server] ?? []);
|
||||
$allowFullUpdate |= $session->userGrade >= 6;
|
||||
|
||||
@@ -244,20 +244,28 @@ if ($server == $baseServerName) {
|
||||
$version = getVersion();
|
||||
$gitHash = getHash();
|
||||
if (
|
||||
hash_file("sha256", __DIR__ . '/' . $server . '/d_setting/VersionGit.dynamic.orig.php') ==
|
||||
hash_file("sha256", __DIR__ . '/' . $server . '/d_setting/VersionGit.php')
|
||||
hash_file("sha256", $settingBasePath . 'VersionGit.dynamic.orig.php') ==
|
||||
hash_file("sha256", $settingBasePath . 'VersionGit.php')
|
||||
) {
|
||||
|
||||
if (file_exists($settingBasePath . 'VersionGit.json')) {
|
||||
unlink($settingBasePath . 'VersionGit.json');
|
||||
}
|
||||
$result = true;
|
||||
} else {
|
||||
$result = Util::generateFileUsingSimpleTemplate(
|
||||
__DIR__ . '/' . $server . '/d_setting/VersionGit.orig.php',
|
||||
__DIR__ . '/' . $server . '/d_setting/VersionGit.php',
|
||||
$settingBasePath . 'VersionGit.orig.php',
|
||||
$settingBasePath . 'VersionGit.php',
|
||||
[
|
||||
'verionGit' => $version,
|
||||
'hash' => $gitHash
|
||||
],
|
||||
true
|
||||
);
|
||||
file_put_contents($settingBasePath . 'VersionGit.json', Json::encode([
|
||||
'versionGit' => $version,
|
||||
'hash' => $gitHash,
|
||||
]));
|
||||
}
|
||||
|
||||
//git 업데이트했는데, package.json이 바뀌면 곤란하니까
|
||||
@@ -333,14 +341,18 @@ $zip->close();
|
||||
$version = getVersion($target);
|
||||
$gitHash = getHash($target);
|
||||
$result = Util::generateFileUsingSimpleTemplate(
|
||||
__DIR__ . '/' . $server . '/d_setting/VersionGit.orig.php',
|
||||
__DIR__ . '/' . $server . '/d_setting/VersionGit.php',
|
||||
$settingBasePath . 'VersionGit.orig.php',
|
||||
$settingBasePath . 'VersionGit.php',
|
||||
[
|
||||
'verionGit' => $version,
|
||||
'hash' => $gitHash
|
||||
],
|
||||
true
|
||||
);
|
||||
file_put_contents($settingBasePath . 'VersionGit.json', Json::encode([
|
||||
'versionGit' => $version,
|
||||
'hash' => $gitHash,
|
||||
]));
|
||||
genJS($server);
|
||||
|
||||
$storage->$server = [$target, $version];
|
||||
|
||||
+60
-50
@@ -6,12 +6,41 @@ const { resolve } = require('path');
|
||||
const CleanTerminalPlugin = require('clean-terminal-webpack-plugin');
|
||||
const { ESBuildMinifyPlugin } = require('esbuild-loader')
|
||||
const webpack = require('webpack');
|
||||
const fs = require('fs');
|
||||
module.exports = (env, argv) => {
|
||||
const target = env.target ?? 'hwe';
|
||||
const mode = argv.mode ?? 'production';
|
||||
const tsDir = resolve(__dirname, `${target}/ts/`);
|
||||
const build_exports = require(`${tsDir}/build_exports.json`);
|
||||
|
||||
const versionGitPath = resolve(__dirname, target, 'd_setting', 'VersionGit.json');
|
||||
|
||||
const versionValue = (() => {
|
||||
if (!fs.existsSync(versionGitPath)) {
|
||||
return undefined;
|
||||
}
|
||||
const versionInfo = JSON.parse(fs.readFileSync(versionGitPath, 'utf-8'));
|
||||
return versionInfo.versionGit;
|
||||
})()
|
||||
const versionTarget = versionValue ?? `${target}_dynamic`;
|
||||
const outputPath = resolve(__dirname, 'dist_js', versionTarget);
|
||||
fs.mkdirSync(outputPath, {
|
||||
recursive: true
|
||||
});
|
||||
|
||||
const genBuildHook = function (oTarget) {
|
||||
const checkFilePath = resolve(outputPath, `build_${oTarget}.txt`);
|
||||
return function (percentage, msg) {
|
||||
if (percentage == 0) {
|
||||
if (fs.existsSync(checkFilePath)) {
|
||||
fs.unlinkSync(checkFilePath);
|
||||
}
|
||||
} else if (percentage == 1) {
|
||||
fs.writeFileSync(checkFilePath, new Date().toISOString(), 'utf-8');
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
//TODO: esbuild에 browserslist 사용 가능하면 적용
|
||||
|
||||
//서버마다 ts 파일 구성이 다를 가능성이 높기 때문에 어떤 파일이 필요한지는 ts/build_exports.json을 확인한다.
|
||||
@@ -25,7 +54,7 @@ module.exports = (env, argv) => {
|
||||
}
|
||||
|
||||
const ingame_vue = {
|
||||
name: `ingame_${target}_vue`,
|
||||
name: `ingame_${versionTarget}_vue`,
|
||||
resolve: {
|
||||
extensions: [".ts", ".tsx", ".vue", ".js"],
|
||||
alias: {
|
||||
@@ -39,7 +68,7 @@ module.exports = (env, argv) => {
|
||||
entry: entryIngameVue,
|
||||
output: {
|
||||
filename: '[name].js',
|
||||
path: resolve(__dirname, `${target}/dist_js`)
|
||||
path: resolve(outputPath, 'vue')
|
||||
},
|
||||
devtool: 'source-map',
|
||||
optimization: {
|
||||
@@ -128,56 +157,27 @@ module.exports = (env, argv) => {
|
||||
},
|
||||
{
|
||||
test: /\.(png|jpe?g|gif|webp)$/,
|
||||
use: [
|
||||
{
|
||||
loader: 'file-loader',
|
||||
options: {
|
||||
name: '../dist_misc/[name].[contenthash:8].[ext]'
|
||||
}
|
||||
}
|
||||
]
|
||||
use: ['file-loader']
|
||||
},
|
||||
{
|
||||
test: /\.(svg)$/,
|
||||
use: [
|
||||
{
|
||||
loader: 'file-loader',
|
||||
options: {
|
||||
name: '../dist_misc/[name].[contenthash:8].[ext]'
|
||||
}
|
||||
}
|
||||
]
|
||||
use: ['file-loader']
|
||||
},
|
||||
{
|
||||
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)$/,
|
||||
use: [
|
||||
{
|
||||
loader: 'file-loader',
|
||||
options: {
|
||||
name: '../dist_misc/[name].[contenthash:8].[ext]'
|
||||
}
|
||||
}
|
||||
]
|
||||
use: ['file-loader']
|
||||
},
|
||||
{
|
||||
test: /\.(woff2?|eot|ttf|otf)$/i,
|
||||
use: [
|
||||
{
|
||||
loader: 'file-loader',
|
||||
options: {
|
||||
name: '../dist_misc/[name].[contenthash:8].[ext]'
|
||||
}
|
||||
}
|
||||
]
|
||||
use: ['file-loader']
|
||||
},
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
new CleanTerminalPlugin(),
|
||||
new VueLoaderPlugin(),
|
||||
new MiniCssExtractPlugin({
|
||||
filename: '../dist_css/[name].css'
|
||||
}),
|
||||
new MiniCssExtractPlugin(),
|
||||
new webpack.ProgressPlugin(genBuildHook('vue')),
|
||||
//new BundleAnalyzerPlugin()
|
||||
],
|
||||
cache: {
|
||||
@@ -185,7 +185,7 @@ module.exports = (env, argv) => {
|
||||
},
|
||||
};
|
||||
const ingame = {
|
||||
name: `ingame_${target}`,
|
||||
name: `ingame_${versionTarget}`,
|
||||
resolve: {
|
||||
extensions: [".js", ".ts", ".tsx"],
|
||||
alias: {
|
||||
@@ -198,7 +198,7 @@ module.exports = (env, argv) => {
|
||||
entry: entryIngame,
|
||||
output: {
|
||||
filename: '[name].js',
|
||||
path: resolve(__dirname, `${target}/dist_js`)
|
||||
path: resolve(outputPath, 'ts')
|
||||
},
|
||||
devtool: 'source-map',
|
||||
optimization: {
|
||||
@@ -272,9 +272,8 @@ module.exports = (env, argv) => {
|
||||
},
|
||||
plugins: [
|
||||
new CleanTerminalPlugin(),
|
||||
new MiniCssExtractPlugin({
|
||||
filename: '../dist_css/[name].css'
|
||||
}),
|
||||
new MiniCssExtractPlugin(),
|
||||
new webpack.ProgressPlugin(genBuildHook('ts')),
|
||||
//new BundleAnalyzerPlugin()
|
||||
],
|
||||
cache: {
|
||||
@@ -287,7 +286,7 @@ module.exports = (env, argv) => {
|
||||
}
|
||||
};
|
||||
const gateway = {
|
||||
name: 'gateway',
|
||||
name: `gateway_${versionTarget}`,
|
||||
resolve: {
|
||||
extensions: [".js", ".ts", ".tsx"],
|
||||
alias: {
|
||||
@@ -307,7 +306,7 @@ module.exports = (env, argv) => {
|
||||
},
|
||||
output: {
|
||||
filename: '[name].js',
|
||||
path: path.resolve(__dirname, 'dist_js'),
|
||||
path: resolve(outputPath, 'gateway')
|
||||
},
|
||||
devtool: 'source-map',
|
||||
optimization: {
|
||||
@@ -379,9 +378,8 @@ module.exports = (env, argv) => {
|
||||
}]
|
||||
},
|
||||
plugins: [
|
||||
new MiniCssExtractPlugin({
|
||||
filename: '../dist_css/[name].css'
|
||||
}),
|
||||
new MiniCssExtractPlugin(),
|
||||
new webpack.ProgressPlugin(genBuildHook('gateway')),
|
||||
//new BundleAnalyzerPlugin()
|
||||
],
|
||||
cache: {
|
||||
@@ -389,10 +387,22 @@ module.exports = (env, argv) => {
|
||||
},
|
||||
};
|
||||
|
||||
if (target == 'hwe') {
|
||||
if(env.WEBPACK_WATCH || !versionValue){
|
||||
return [gateway, ingame_vue, ingame];
|
||||
}
|
||||
else {
|
||||
return [ingame_vue, ingame];
|
||||
|
||||
const buildConfList = [];
|
||||
if (target == 'hwe' && !fs.existsSync(resolve(outputPath, `build_gateway.txt`))) {
|
||||
buildConfList.push(gateway);
|
||||
}
|
||||
|
||||
if (!fs.existsSync(resolve(outputPath, `build_vue.txt`))) {
|
||||
buildConfList.push(ingame_vue);
|
||||
}
|
||||
|
||||
if (!fs.existsSync(resolve(outputPath, `build_ts.txt`))) {
|
||||
buildConfList.push(ingame);
|
||||
}
|
||||
|
||||
return buildConfList;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user