Exclude files
Hello all,
I have used webpack obfuscator previous version for webpack 4 with laravel mix. Now I have been trying this version and it works great, but when it tried to build the service worker always gives me an error saying that it cant find the self.__manifest. I realized that probably some files are being obfuscated and they should not. So, I decided to exclude the files that I was excluding before, but after trying some things, reading the docs and look to the webpackObfuscatorPlugin class and apply what it looks like its the correct way I am not being able to exclude the files I want.
This is the block of code that I am using:
if (mix.inProduction()) {
/**
* PWA code
*/
mix.injectManifest({
swSrc: './resources/js/service-worker.js',
swDest: path.join(`${__dirname}/public`, 'service-worker.js'),
mode: 'production',
});
mix.webpackConfig({
plugins: [
new WebpackObfuscator({
//rotateStringArray: true,
compact: true,
controlFlowFlattening: false,
deadCodeInjection: false,
debugProtection: false,
debugProtectionInterval: 0,
disableConsoleOutput: false,
identifierNamesGenerator: 'hexadecimal',
log: false,
numbersToExpressions: false,
renameGlobals: false,
selfDefending: false,
simplify: true,
splitStrings: false,
stringArray: true,
stringArrayCallsTransform: false,
stringArrayCallsTransformThreshold: 0.5,
stringArrayEncoding: [],
stringArrayIndexShift: true,
stringArrayRotate: true,
stringArrayShuffle: true,
stringArrayWrappersCount: 1,
stringArrayWrappersChainedCalls: true,
stringArrayWrappersParametersMaxCount: 2,
stringArrayWrappersType: 'variable',
stringArrayThreshold: 0.75,
unicodeEscapeSequence: false,
},
[
path.join(__dirname, 'node_modules'),
path.join(__dirname, 'resources/js/app.js'),
path.join(__dirname, 'resources/js/bootstrap.js'),
path.join(__dirname, 'resources/js/service-worker.js'),
]),
],
});
}
Before this I do all the mix.js() to the files that I need for dev and production.
I am missing something important for sure, but can't find what I am doing wrong to exclude those files.
Maybe some mix function as it could be done in the old version?
mix.serve('php artisan lang:js')
.obfuscator({
options: {
compact: true,
controlFlowFlattening: false,
deadCodeInjection: false,
debugProtection: false,
debugProtectionInterval: 0,
disableConsoleOutput: false,
identifierNamesGenerator: 'hexadecimal',
log: false,
numbersToExpressions: false,
renameGlobals: false,
selfDefending: false,
simplify: true,
splitStrings: false,
stringArray: true,
stringArrayCallsTransform: false,
stringArrayCallsTransformThreshold: 0.5,
stringArrayEncoding: [],
stringArrayIndexShift: true,
stringArrayRotate: true,
stringArrayShuffle: true,
stringArrayWrappersCount: 1,
stringArrayWrappersChainedCalls: true,
stringArrayWrappersParametersMaxCount: 2,
stringArrayWrappersType: 'variable',
stringArrayThreshold: 0.75,
unicodeEscapeSequence: false
},
exclude: [
path.resolve(__dirname, 'node_modules'),
path.resolve(__dirname, 'resources/js/app.js'),
path.resolve(__dirname, 'resources/js/bootstrap.js'),
path.resolve(__dirname, 'resources/js/service-worker.js'),
]
});
}
Thank you for the help :)