Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to minify typescript source code in electron app using electron-forge and electron-packager?

edit: I solved this by using electron-builder, it uses webpack under the hood so all problems are handled well by default. I post this question as I used electron-forge and electron-packager at first, and although I searched several resources I still couldn't wrap my head about the difference among electron-forge/electron-packager/electron-builder 😂

original question:

I built an electron app with electron-forge using react and typescript, but I found out it contains my whole typescript source code in the distribution.

After dug around, it seems that there's no way to get rid of the source, even asar could be extracted easily. Minifying the source code may be the most "proper" way to keep others from just copy and paste my project. I figured may be I can achieve this by utilizing the afterCopy hooks provided by electron-packager, but don't know how exactly I should do it, any suggestions?

like image 468
Drake Xiang Avatar asked Nov 07 '22 13:11

Drake Xiang


1 Answers

You can use bytenode for compiling all your js files into bytecode and it will be literally unreadable by humans. But it is quite hacky.

like image 91
sanperrier Avatar answered Nov 15 '22 11:11

sanperrier