Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude files #166

Open
ALGAzevedo opened this issue Aug 7, 2023 · 0 comments
Open

Exclude files #166

ALGAzevedo opened this issue Aug 7, 2023 · 0 comments

Comments

@ALGAzevedo
Copy link

ALGAzevedo commented Aug 7, 2023

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant