Browse Source

ref: build tools improvements

Sv443 1 year ago
parent
commit
ee2494a3f0
3 changed files with 7 additions and 5 deletions
  1. 1 1
      src/index.ts
  2. 3 3
      src/tools/post-build.ts
  3. 3 1
      webpack.config.js

+ 1 - 1
src/index.ts

@@ -27,7 +27,7 @@ const preloadImgs = [
 {
   // console watermark with sexy gradient
   const styleGradient = "background: rgba(165, 38, 38, 1); background: linear-gradient(90deg, rgb(154, 31, 103) 0%, rgb(135, 31, 31) 40%, rgb(184, 64, 41) 100%);";
-  const styleCommon = "color: #fff; font-size: 1.25em; padding-left: 8px; padding-right: 8px;";
+  const styleCommon = "color: #fff; font-size: 1.35em; padding-left: 6px; padding-right: 6px;";
 
   console.log();
   console.log(

+ 3 - 3
src/tools/post-build.ts

@@ -76,7 +76,7 @@ type BuildStats = {
     const lastCommitSha = await getLastCommitSha();
 
     const scriptPath = join(rootPath, distFolderPath, userscriptDistFile);
-    const globalStylePath = join(rootPath, distFolderPath, "main.css");
+    const globalStylePath = join(rootPath, distFolderPath, "global.css");
     let globalStyle = String(await readFile(globalStylePath));
     if(mode === "production")
       globalStyle = remSourcemapComments(globalStyle);
@@ -159,12 +159,12 @@ function remSourcemapComments(input: string) {
  */
 function getLastCommitSha() {
   return new Promise<string>((res, rej) => {
-    exec("git rev-parse HEAD", (err, stdout, stderr) => {
+    exec("git rev-parse --short HEAD", (err, stdout, stderr) => {
       if(err) {
         console.error("\x1b[31mError while checking for last Git commit. Do you have Git installed?\x1b[0m\n", stderr);
         return rej(err);
       }
-      return res(String(stdout).replace(/\r?\n/gm, "").trim().substring(0, 7));
+      return res(String(stdout).replace(/\r?\n/gm, "").trim());
     });
   });
 }

+ 3 - 1
webpack.config.js

@@ -77,7 +77,9 @@ const getConfig = (env) => {
       ],
     },
     plugins: [
-      new MiniCssExtractPlugin(),
+      new MiniCssExtractPlugin({
+        filename: "global.css",
+      }),
       {
         apply: (compiler) => {
           console.log("Running post-build script...\n");