Skip to content

Commit 4d1c149

Browse files
authored
Minify CSS and JS (#66)
1 parent e434620 commit 4d1c149

File tree

5 files changed

+24
-12
lines changed

5 files changed

+24
-12
lines changed

build.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ abstract class Main {
2828
fs.copyFileSync(path.join(src, file), path.join(dist, file));
2929
}
3030

31+
/* minify */ {
32+
for(const file of ["index.js", "style.css"])
33+
fs.writeFileSync(path.join(dist, file), fs.readFileSync(path.join(dist, file), "utf-8")
34+
.replace(/(?<!^)\/\*.*\*\//g, '') // /* comments (except first copyright)
35+
.replace(/ \/\/.*$/gm,'') // // comments
36+
.replace(/ +/gm, ' ') // extra spaces
37+
.replace(/^ +/gm, '') // leading space
38+
.replace(/\r?\n/gm, '') // new line
39+
.trim());
40+
}
41+
3142
/* chrome */ {
3243
await zip(dist, chrome);
3344
}

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
},
1818
"homepage": "https://github.com/KatsuteDev/GitHub-Red-Issues#readme",
1919
"devDependencies": {
20-
"@types/node": "18.7.6",
20+
"@types/node": "18.7.23",
2121
"typescript": "4.8.4",
2222
"zip-a-folder": "1.1.5"
2323
}
24-
}
24+
}

src/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2022 Katsute <https://github.com/Katsute>
1+
/* Copyright (C) 2022 Katsute <https://github.com/Katsute> */
22

33
"use strict";
44

@@ -8,9 +8,9 @@ const whenElementAdded = (selector, f) => {
88
if(e != null){
99
f(e);
1010
clearInterval(init);
11-
}
11+
};
1212
}, 1000 * 1);
13-
}
13+
};
1414

1515
if(window.location.pathname.toLowerCase().includes("/projects/"))
1616
whenElementAdded(`#__primerPortalRoot__`, (e) => {

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"compilerOptions": {
33
"target": "es2020",
44
"module": "commonjs",
5+
"alwaysStrict": true,
56
"strict": true,
67
"skipLibCheck": true,
78
"removeComments": true

0 commit comments

Comments
 (0)