mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-07-11 08:03:13 +01:00
Background fill the .ico
- Add additional ignores/msbuild deletes to icon gen script
This commit is contained in:
@@ -30,3 +30,5 @@ packaging/
|
||||
/src/Tgstation.Server.Common/node_modules
|
||||
/src/Tgstation.Server.Common/package.json
|
||||
/src/Tgstation.Server.Common/yarn.lock
|
||||
/src/Tgstation.Server.Common/logo_bg_white.svg
|
||||
yarn-error.log*
|
||||
|
||||
+5
-1
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 7.7 KiB After Width: | Height: | Size: 14 KiB |
@@ -10,7 +10,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- This is here because I know we have node as a build dep so this just works -->
|
||||
<Target Name="IconGeneration" BeforeTargets="ResolveAssemblyReferences" Inputs="../../build/logo.svg" Outputs="../../artifacts/tgs.ico;../../artifacts/tgs.png">
|
||||
<Target Name="IconGeneration" BeforeTargets="ResolveAssemblyReferences" Inputs="build_logo.js;../../build/logo.svg" Outputs="../../artifacts/tgs.ico;../../artifacts/tgs.png">
|
||||
<Message Text="Restoring yarn packages..." Importance="high" />
|
||||
<Exec Command="npx --yes yarn add svg-to-ico@1.0.14 svg2img@1.0.0-beta.2" />
|
||||
<Message Text="Generating icons from SVG..." Importance="high" />
|
||||
@@ -24,6 +24,6 @@
|
||||
|
||||
<Target Name="IconNodeCleanup" AfterTargets="IconGeneration;IconClean">
|
||||
<RemoveDir Directories="node_modules" />
|
||||
<Delete Files="package.json;yarn.lock" />
|
||||
<Delete Files="package.json;yarn.lock;logo_bg_white.svg;yarn-error.log" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Prereq packages: svg-to-ico@1.0.14 svg2img@1.0.0-beta.2
|
||||
// Usage: node ./build_logo.js
|
||||
// Generates ../../artifacts/tgs.ico and ../../artifacts/tgs.ico
|
||||
// Generates ../../artifacts/tgs.ico and ../../artifacts/tgs.ico
|
||||
|
||||
const svg_to_img = require("svg-to-ico");
|
||||
const svg2img = require('svg2img');
|
||||
@@ -10,12 +10,19 @@ if (!fs.existsSync("../../artifacts")) {
|
||||
fs.mkdirSync("../../artifacts",'0777', true);
|
||||
}
|
||||
|
||||
const svg_bytes = fs.readFileSync("../../build/logo.svg");
|
||||
const svg = svg_bytes.toString();
|
||||
const white_bg_svg = svg
|
||||
.replace("<!-- DO NOT CHANGE THIS LINE, UNCOMMENTING IT ENABLES THE WHITE BACKGROUND FOR THE .ICO--><!--", "")
|
||||
.replace("SCRIPT_REPLACE_TOKEN", "");
|
||||
fs.writeFileSync("logo_white_bg.svg", white_bg_svg);
|
||||
|
||||
svg_to_img({
|
||||
input_name: "../../build/logo.svg",
|
||||
input_name: "logo_white_bg.svg",
|
||||
output_name: "../../artifacts/tgs.ico",
|
||||
sizes: [ 160 ]
|
||||
}).then(() => {
|
||||
// this package sucks, path separators are fucked
|
||||
fs.unlinkSync("logo_white_bg.svg");
|
||||
svg2img(
|
||||
"../../build/logo.svg",
|
||||
{
|
||||
@@ -35,6 +42,7 @@ svg_to_img({
|
||||
fs.writeFileSync("../../artifacts/tgs.png", buffer);
|
||||
});
|
||||
}).catch((error) => {
|
||||
console.error(`ICO conversion failed: ${error}`);
|
||||
exit(1);
|
||||
fs.unlinkSync("logo_white_bg.svg");
|
||||
console.error(`ICO conversion failed: ${error}`);
|
||||
exit(1);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user