Giter VIP home page Giter VIP logo

gulp-javascript-obfuscator's Introduction

gulp-javascript-obfuscator

Gulp plugin for javascript-obfuscator

Installation

Install the package with npm:

$ npm install --save gulp-javascript-obfuscator

Usage

const gulp = require('gulp');
const javascriptObfuscator = require('gulp-javascript-obfuscator');

gulp.src('file.js')
    .pipe(javascriptObfuscator())
    .pipe(gulp.dest('dist'));

Options

Pass any options available in the obfuscator

gulp.src('file.js')
    .pipe(javascriptObfuscator({
        compact: true
    }))
    .pipe(gulp.dest('dist'));

The only exception is obfuscator's sourceMap option which must not be set, as it will be handled automatically when using gulp-sourcemaps.

Source Maps

With version 1.1.6 onwards, gulp-javascript-obfuscator can be used in tandem with gulp-sourcemaps in order to generate source maps for your javascript files.

You will need to initialize gulp-sourcemaps prior to running gulp-javascript-obfuscator and write the source maps after, as such:

const sourcemaps = require('gulp-sourcemaps');

gulp.src('file.js')
    .pipe(sourcemaps.init())
    .pipe(javascriptObfuscator({
        compact: true
    }))
    .pipe(sourcemaps.write())
    .pipe(gulp.dest('dist'));

This will output a file.js.map file to the dist directory.

You can chain other gulp plugins as well:

const sourcemaps = require('gulp-sourcemaps');

gulp.src('file.js')
    .pipe(sourcemaps.init())
    // use babel to pre-process javascript files
    .pipe(babel({
        presets: ['@babel/preset-env']
    }))
    .pipe(javascriptObfuscator({
        compact: true
    }))
    .pipe(sourcemaps.write())
    .pipe(gulp.dest('dist'));

Alternative source maps method

For backwards compatibility, if gulp-sourcemaps is not used and obfuscator's sourceMap option is set to true, a .map file will be thrown to Gulp stream. (This method is deprecated and not recommended for future use.)

gulp-javascript-obfuscator's People

Contributors

wain-pc avatar drsdavidsoft avatar mike-eason avatar kukunin avatar

Watchers

James Cloos avatar  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.