Skip to content

Instantly share code, notes, and snippets.

@niccolomineo
Last active July 25, 2024 08:42
Show Gist options
  • Save niccolomineo/a9cf92ce972d9e4aa4a5dfe5f3f75ec1 to your computer and use it in GitHub Desktop.
Save niccolomineo/a9cf92ce972d9e4aa4a5dfe5f3f75ec1 to your computer and use it in GitHub Desktop.
A Webpack configuration for obfuscating JavaScript in an Electron.js app
const Path = require('path'),
NodeExternals = require('webpack-node-externals'),
Copy = require('copy-webpack-plugin'),
Obfuscator = require('webpack-obfuscator')
module.exports = {
context: __dirname,
mode: 'production',
target: 'electron-main',
entry: {
main: path.resolve('./app/js/main.js'),
renderer: path.resolve('./app/js/renderer.js'),
},
plugins: [
new Copy({
patterns: [
{
from: './package.json',
to: './package.json'
},
{
from: './src',
to: './src',
globOptions: {
ignore: ['js/**/*']
}
}
]
}),
new Obfuscator({
rotateUnicodeArray: true
}),
],
node: {
__dirname: false,
global: true
},
output: {
path: Path.resolve('./dist/orig'),
filename: 'src/js/[name].js'
},
externals: [NodeExternals({ modulesFromFile: true })]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment