代码混淆的执行顺序

时间:2016-05-03 05:55:16

标签: javascript ionic-framework gulp

我正在尝试使用gulp实用程序来混淆我的JS代码。 [离子应用]

gulp.task('ng_annotate_app',function (done) {
      gulp.src(['!www/js/toaster.min.js','www/js/*.js','www/common/*.js'])
        .pipe(strip())
          .pipe(stripDebug())
          .pipe(rename({
              suffix: ".min",
              extname: ".js"
          }))
          .pipe(uglify({mangle: false}))
          .pipe(ngAnnotate({single_quotes: true}))
          .(obfuscate())
      .pipe(gulp.dest('www/dist'))
      .on('end', done);
    });

我的文件a.js中的角度模块启动器和b.js中的工厂如下所示。 a.js:

var mod=angular.module ...

b.js

mod.factory ...

上面的var mod在a.js中被混淆到一些虚拟字符串但是在b.js中它没有改变。因为我的应用程序显示错误而无法运行。

非常感谢帮助!

2 个答案:

答案 0 :(得分:0)

在我看来,不要将变量从一个文件用到另一个文件。您可以使用mod.factory

,而不是使用angular.module('<Your module name>').factory

或者您可以将相关文件分组到另一个模块中,例如angular.module('<another module name>',[]).factory然后将此模块包含在主模块文件的依赖项中(主要是app.js)angular.module('myApp', ['<another module name>'])

答案 1 :(得分:0)

我有同样的问题..你需要使用一个工具,确保它查看所有提交的文件,并在所有文件上保持相同的名称,而不是破坏任何依赖。 Jscrambler保证并为我工作。