Skip to content
This repository has been archived by the owner on Aug 17, 2024. It is now read-only.

javiluli/gulpjs-obfuscate-minified

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JavaScript ofuscado y minificado con Gulp.js

Instalar dependencias

npm i

Iniciar script de Gulp

npx gulp start

Configurar fichero principal gulpfile.js

Require necesario

const { src, dest, watch } = require('gulp')
const javascriptObfuscator = require('gulp-javascript-obfuscator')
const uglify = require('gulp-uglify')
const rename = require('gulp-rename')

Función principal que maneja las dependencias de gulp

const bundleJs = function () {
  return (
    src('src/js/*.js')
      // Genera el codigo fuente como ofuscado
      .pipe(javascriptObfuscator())
      // Genera codigo minificado
      .pipe(uglify())
      // Renombra un fichero generado
      .pipe(rename({ extname: '.min.js' }))
      // Directorio de destino
      .pipe(dest('./dist/js/'))
  )
}

Función escuchador de gulp

const start = () => watch('./src/js/*.js', bundleJs)

Exportar tarea de gulp

exports.start = start