gulp-obfuscate icon indicating copy to clipboard operation
gulp-obfuscate copied to clipboard

Uncaught SyntaxError: Invalid or Unexpected token

Open junerockwell opened this issue 8 years ago • 0 comments
trafficstars

Chrome won't run my JavaScript app. The browser display's all white. It says: screen shot 2017-08-27 at 11 49 42 am

In Firefox, nothing's in the console but screen is also just white. The content of the app before obfuscation is a black box with text inside it.

At first, it didn't like a var someVar = new Image(); So I commented it out because I never used it. And then it doesn't like var counter = 0;. And both are from the very first js file that was concatenated using gulp-concat. And they are the first 2 lines of the code in a concatenated js file and the obfuscated file.

gulpfile.js

var gulp = require('gulp'),
    connect = require('gulp-connect'),
    concat = require('gulp-concat'),
    uglify = require('gulp-uglify'),
    rename = require('gulp-rename'),
    babel = require('gulp-babel'),
    obfuscate = require('gulp-obfuscate');

gulp.task('prod', function() {
	return gulp.src([
		'./js/script1.js',
		'./js/script2.js',
		'./js/script3.js'
	])
	.pipe(concat('build.js'))
	.pipe(gulp.dest('./dist'))

	.pipe(babel({
               presets: ['env']
        }))
	.pipe(uglify())
	.pipe(rename('build.min.js'))
  	.pipe(gulp.dest('./dist'))

  	.pipe(obfuscate())
  	.pipe(rename('build.blargh.js'))
  	.pipe(gulp.dest('./dist'))
});
...

package.json

"devDependencies": {
    "babel-core": "^6.26.0",
    "babel-preset-env": "^1.6.0",
    "gulp": "^3.9.1",
    "gulp-babel": "^7.0.0",
    "gulp-concat": "^2.6.1",
    "gulp-connect": "^5.0.0",
    "gulp-obfuscate": "^0.2.9",
    "gulp-rename": "^1.2.2",
    "gulp-uglify": "^3.0.0"
  },
Node v6.9.2
Gulp CLI v1.2.2
Gulp Local v3.9.1
MacOS 10.12.16
Chrome Version 60.0.3112.113 (Official Build) (64-bit)
FireFox 54.0.1 64 Bit

I tried other gulp obfuscates. They work flawlessly, however, the function names and variable names were not obfuscated so I don't really want to use them. I would really prefer this gulp obfuscate plugin because only JS reserved words are not obfuscated. But everything else, like values, variable names, function names all have the LOOK_OF_DISAPPROVAL. But it just doesn't run in Chrome.

Any hint or help would be appreciated. Thanks!

junerockwell avatar Aug 27 '17 19:08 junerockwell