javascript-obfuscator / webpack-obfuscator

javascript-obfuscator plugin for Webpack
https://github.com/javascript-obfuscator/javascript-obfuscator
BSD 2-Clause "Simplified" License
856 stars 84 forks source link

Exclude dont work with webpack "optimization" files. #81

Closed websharik closed 4 years ago

websharik commented 4 years ago

WebPackConfig:

entry: {
    index: ${PATHS.src}/scripts/index.js
},
output: {
    filename: ${PATHS.dist}/scripts/[name].js,
    path: PATHS.dist,
    publicPath: '/'
},
optimization: {
    splitChunks: {
        cacheGroups: {
            vendor: {
                name: 'vendors',
                test: /node_modules/,
                chunks: 'all',
                enforce: true
            }
        }
    }
},
plugins: [
    new JavaScriptObfuscator({
        //...
    }, ['vendors.js'])
]
websharik commented 4 years ago

This works:

plugins: [
    new JavaScriptObfuscator({
        //...
    }, ['scripts/vendors.js'])
]

Example is wrong, excludes is not filenames - its paths to dist files:

module.exports = {
    entry: {
        'abc': './test/input/index.js',
        'cde': './test/input/index1.js'
    },
    output: {
        path: 'dist',
        filename: '[name].js' // output: abc.js, cde.js
    },
    plugins: [
        new JavaScriptObfuscator({
            rotateStringArray: true
        }, ['abc.js'])
    ]
};