Code Monkey home page Code Monkey logo

grunt-contrib-obfuscator's Introduction

grunt-contrib-obfuscator Build Status

Obfuscate JavaScript files using javascript-obfuscator@^2.0.0.

You can try the javascript-obfuscator module and see all its options here: https://obfuscator.io/

Getting Started

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-contrib-obfuscator --save-dev
npm install javascript-obfuscator --save-dev

Notice that you should install manually javascript-obfuscator. This makes it easier to have a newer version of the obfuscator library if needed.

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-contrib-obfuscator');

Obfuscator task

Run this task with the grunt obfuscator command.

Task targets, files and options may be specified according to the grunt Configuring tasks guide.

Options

See the options on the obfuscator repo.

Note that at this time the sourceMap isn't implemented in this plugin.

In addition to the obfuscator options, you can also use:

banner

Type: String Default: ''

This string will be prepended to the obfuscated output. Template strings (e.g. <%= config.value %> will be expanded automatically.

Usage examples

Default options

This configuration will obfuscate the input files using the default options.

obfuscator: {
    options: {
        // global options for the obfuscator
    },
    task1: {
        options: {
            // options for each sub task
        },
        files: {
            'dest/output.js': [
                'src/js/file1.js',
                'src/js/file2.js'
            ]
        }
    }
}

This configuration will obfuscate the input files in a destination folder by keeping the original names and directories

obfuscator: {
    options: {
        // global options for the obfuscator
    },
    task1: {
        options: {
            // options for each sub task
        },
        files: {
            'dest/': [ // the files and their directories will be created in this folder
                'src/js/file1.js',
                'src/js/folder/file2.js'
            ]
        }
    }
}

Debug protection and banner

Here you code will be protected against debugging and locked to the domain www.example.com.

obfuscator: {
    options: {
        banner: '// obfuscated with grunt-contrib-obfuscator.\n',
        debugProtection: true,
        debugProtectionInterval: true,
        domainLock: ['www.example.com']
    },
    task1: {
        options: {
            // options for each sub task
        },
        files: {
            'dest/output.js': [
                'src/js/file1.js',
                'src/js/file2.js'
            ]
        }
    }
}

grunt-contrib-obfuscator's People

Contributors

slig avatar nancel avatar sanex3339 avatar rvalitov avatar dependabot[bot] avatar lpmi-13 avatar lamweili avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.