0

I am trying to minify my code with my code in gulp I can create a folder called _build where I optimize my code, minifying it and returning it uglify and apparently it is minified but it is no longer a valid code for angular.js an example is:

angularRoutingApp.controller('homeController', function($scope,$state,$http,$timeout,$window,alerta,preload){

to

angularRoutingApp.controller("homeController",function(e,o,i,a,n,r,t)

in this line of code is where I convert my controller to uglify

controllers:[$.uglify()],

this is my code:

    gulp.task('minify-js', function() {
      gulp.src('js/*.js')
        .pipe($.uglify())
        .pipe(gulp.dest('./_build/'));
    });

    gulp.task('minify-css', function() {
      gulp.src(['./css/**/*.css'])
        .pipe($.rename({suffix: '.min'}))
        .pipe($.minifyCss({keepBreaks:true}))
        .pipe(gulp.dest('./css/'))
        .pipe(gulp.dest('./_build/css/'));
    });

    gulp.task('minify-html', function() {
      var opts = {
        comments: true,
        spare: true,
        conditionals: true
      };

      gulp.src('./*.html')
        .pipe($.minifyHtml(opts))
        .pipe(gulp.dest('./_build/'));
    });

    gulp.task('fonts', function() {
      gulp.src('./fonts/**/*.{ttf,woff,eof,eot,svg}')
        .pipe($.changed('./_build/fonts'))
        .pipe(gulp.dest('./_build/fonts'));
    });

    gulp.task('server', function(done) {
      return browserSync({
        server: {
          baseDir: './'
        }
      }, done);
    });

    gulp.task('server-build', function(done) {
      return browserSync({
        server: {
          baseDir: './_build/'
        }
      }, done);
    });

    gulp.task('clean:build', function (cb) {
      del([
        './_build/'
        // if we don't want to clean any file we can use negate pattern
        //'!dist/mobile/deploy.json'
      ], cb);
    });

    require('events').EventEmitter.prototype._maxListeners = 100;


    gulp.task('usemin', function() {
      return gulp.src('./index.html')
        // add templates path
        .pipe($.htmlReplace({
          'templates': '<script type="text/javascript" src="js/templates.js"></script>'
        }))
        .pipe($.usemin({
          css: [$.minifyCss(), 'concat'],
          libs: [$.uglify()],
          nonangularlibs: [$.uglify()],
          angularlibs: [$.uglify()],
          controllers:[$.uglify()],
          contservicesapp:[$.uglify()],
          services:[$.uglify()],
          appcomponents: [$.uglify()],
          mainapp: [$.uglify()],
          templates:[$.uglify()],
          directives:[$.uglify()]
        }))
        .pipe(gulp.dest('./_build/'));
    });

how can I solve that?

3

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.