# Disable uglify in Gulpfile

**URL:** https://discourse.roots.io/t/disable-uglify-in-gulpfile/3117
**Category:** sage
**Tags:** gulp
**Created:** 2015-03-06T00:58:41Z
**Posts:** 9

## Post 1 by @aaronjheinen — 2015-03-06T00:58:41Z

Gulp is uglifying angular dependencies and causing errors, how do I tell it not to uglify certain files?

Also, Can a “gulp” category be added?

---

## Post 2 by @austin — 2015-03-06T01:57:19Z

You should be using [https://github.com/Kagami/gulp-ng-annotate/blob/master/README.md](https://github.com/Kagami/gulp-ng-annotate/blob/master/README.md)

---

## Post 3 by @aaronjheinen — 2015-03-09T20:25:37Z

Worked great! Thanks.

---

## Post 4 by @austin — 2015-03-09T20:31:03Z

For posterity: The thing in Uglify that breaks angular is the [mangler](https://github.com/mishoo/UglifyJS2/blob/ae07714927f44790e40628cde4fa57bc2c4cb076/README.md#mangler-options). You can disable mangling in uglify but I would not recommend it. Most of the actual runtime perf benefits of uglifying comes from mangling. So that’s why I recommend using ng-annotate. Definitely always recommend using [ngStrictDi](https://docs.angularjs.org/api/ng/directive/ngApp) if you are on 1.3.

> [ngScriptDi] if this attribute is present on the app element, the injector will be created in “strict-di” mode. This means that the application will fail to invoke functions which do not use explicit function annotation (and are thus unsuitable for minification), as described in the Dependency Injection guide, and useful debugging info will assist in tracking down the root of these bugs.

---

## Post 5 by @aaron_jj_sims — 2015-04-29T02:41:22Z

Hi, I am trying to use angular js on a project that I am playing around with based on Sage.

Sorry I am new to gulp and Roots/Sage, but familiar with angular/word press and have used grunt a little bit.

I have a recent version of Sage.

I am getting “Unknown provider: tProvider \<- t \<- mainController”

if i comment out .pipe($.uglify) in gulpfile.js its fine.

I have installed gulp-ng-annotate but not sure what i need to do get it doing its magic.

Im guessing i need to modify a few processes in gulpfile.js, but not really sure were to begin apart form adding:

```
var ngAnnotate = require('gulp-ng-annotate');
```

Any help would be greatly appreciated, please elaborate as much as possible as your dealing with a bit of a newbie.

Cheers

---

## Post 6 by @aaronjheinen — 2015-04-29T15:22:23Z

Add

```
.pipe(ngAnnotate)
```

before

```
.pipe($.uglify)
```

my jsTasks looks like this:

```
var jsTasks = function(filename) {
  return lazypipe()
  .pipe(function() {
    return $.if(enabled.maps, $.sourcemaps.init());
  })
  .pipe(ngAnnotate)
  .pipe($.concat, filename)
  .pipe($.uglify)
  .pipe(function() {
    return $.if(enabled.rev, $.rev());
  })
  .pipe(function() {
    return $.if(enabled.maps, $.sourcemaps.write('.'));
  })();
};
```

---

## Post 7 by @aaron_jj_sims — 2015-05-01T04:22:34Z

Thanks, that has worked perfect and thanks for being very clear

---

## Post 8 by @nicmare — 2015-05-04T18:10:42Z

anyways is there a “clean” way to disable uglify? i commented it out in gulpfile now.

---

## Post 9 by @austin — 2015-05-04T18:52:06Z

Hide it behind a flag
