javascript-obfuscator / webpack-obfuscator

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

How do i exclude node_modules with the plugin? #125

Closed Directory closed 3 years ago

Directory commented 3 years ago

This was asked in #109 but nobody answered. i can not use the loader i have to use the plugin. how can i exclude node_modules like i do with loaders?

Directory commented 3 years ago

this seems to work. only downside is you need to have your chunk always named the same. in my case i use chunkIds: 'deterministic' so i hardcoded my vendor chunk id like this

  new WebpackObfuscator({...}, ['456.*.js'])
rinogo commented 2 years ago

You should be able to use something like this (works for me):

...
    output: {
        path: path.resolve(__dirname, '..', 'dist'),
        filename: '[name].bundle.js',
    },
    optimization: {
        splitChunks: {
            chunks: 'all',
            name: 'vendor'
        }
    },
    plugins: [
        new WebpackObfuscator ({
            rotateStringArray: true
        }, ['vendor.bundle.js'])
    ]
...