Is it possible to, to some extent, obfuscate the resulting file coming out of webpack --watch?
For the record i have tried webpack-obfuscator
, but it isn’t strong enough (or maybe i fucked up the setup). code below
const path = require('path');
const TerserPlugin = require('terser-webpack-plugin'); // Terser plugin for minification
var WebpackObfuscator = require('webpack-obfuscator');
module.exports = {
mode: 'production', // Ensures production optimizations (including minification) by default
entry: './Game/main.js', // Adjust this to your entry file
output: {
path: path.resolve(__dirname, 'dist'), // Adjust the output path as necessary
filename: 'bundle.js',
},
devtool: false, // Disables source maps
optimization: {
minimize: true, // Ensures minification is applied
minimizer: [
new TerserPlugin({
terserOptions: {
mangle: {
// Mangle variable names (avoiding `eval` usage)
properties: {
regex: /^(?!_)/, // Avoid mangling private variables that start with "_"
},
},
output: {
// Ensures no source maps are outputted
comments: false,
},
},
extractComments: true// {
//filename: 'licenses.txt', // Specify a filename for the extracted comments
//},
}),
],
},
resolve: {
extensions: ['.js', '.json'], // Adjust according to your needs
},
performance: {
hints: false, // Disable performance hints
},
plugins: [
new WebpackObfuscator ({
rotateStringArray: true
}, ['excluded_bundle_name.js'])
]
};