alex8088 / electron-vite

Next generation Electron build tooling based on Vite 新一代 Electron 开发构建工具,支持源代码保护
https://electron-vite.org
MIT License
3.53k stars 152 forks source link

Still able to see source code inside dist/linux-unpacked/resources/, how to enable code protection against read #235

Closed learncodingforweb closed 1 year ago

learncodingforweb commented 1 year ago

Describe the bug

Steps followed npm create @quick-start/electron, create myapp with react typescript cd myapp && npm i npm build:linux

Still able to see source code inside dist/linux-unpacked/resources/, how to enable code protection against read.

As mention in docs Compile to v8 bytecode to protect source code.

To to make sure code protection against read.

Electron-Vite Version

1.0.25

Electron Version

24.6.2

Vite Version

4.4.2

Validations

alex8088 commented 1 year ago

Protect source code, but not your resources.

learncodingforweb commented 1 year ago

How to make react app content secure by using Uglify / Obfuscator or encryption technique as you have provided provision for code protection against read for node source code not render process, which include frontend ui code like reactjs.

import { defineConfig, bytecodePlugin } from 'electron-vite'

export default defineConfig({
  main: {
    plugins: [bytecodePlugin()]
  },
  preload: {
    plugins: [bytecodePlugin()]
  },
  renderer: {
    // ...
  }
})
alex8088 commented 1 year ago

I think obfuscation don't have much protection, you can minify(build.minify) your code.

xzifan commented 1 year ago

Haven't tried it myself but I guess you could put the sensitive part of the logic into main process (Nodejs) instead of react frontend and use bytecode plugin.