gulp-trim-fn is a small gulp module that obfuscates private functions/properties (with "_"-prefix in their names) in js files (babel-generated code is supported) in order to protect your code.
npm install gulp-trim-fn --save-dev
const gulp = require('gulp');
const trimFn = require('gulp-trim-fn');
gulp.task('trim-fn', () => {
return gulp.src('./src/**/*.js')
.pipe(trimFn())
.pipe(gulp.dest('./lib/'));
});
Before:
function SideBar() {}
SideBar.prototype = {
render: function() {
var data = this._getRenderData();
document.body.innerHTML = this._getTpl().apply(data);
},
_getTpl: function() {},
_getRenderData: function() {},
_getElement: function() {}
}
After:
function SideBar() {}
SideBar.prototype = {
render: function() {
var data = this.a1();
document.body.innerHTML = this.a2().apply(data);
},
a2: function() {},
a1: function() {},
a3: function() {}
}
Created in 2016 by Ruslan Prytula (@milworm).