Search code examples
javascriptnpmgulpbowerminimize

Gulp error when minimize js


I decide to ask because I have been 2 days trying to solve this problem. Im a little bit n00b with this task runner.

I'm using Gulp with Slush using this generator: https://www.npmjs.com/package/slush-webapp

When I run ´gulp serve´ all goes OK and I dont have problems.

But when I run ´gulp´, in the javascript minimice process, I get this error: http://pastebin.com/4mPq2jEU

As I know, CSS is working and it's minimized. Images are working fine too.

When I open the chrome's console I see an error log,saying something about "undefined function"

Tried to solve add in the beggining of the .js files (jquery plugins) the sentence

'use strict'; 

trying to use closures too or something, but is not working.

Any help? Thx,

Jorge


Solution

  • You put in some third-party libraries in your app folder which don't comply to the JSHint rules. That's why you get that fat error stack. Things you can do:

    1. Open your Gulpfile, and remove the JSHint task from your build:

      gulp.task('build', ['lint', 'html', 'images', 'fonts', 'misc']);
      
      /* to */
      
      gulp.task('build', ['html', 'images', 'fonts', 'misc']);
      
    2. exclude the third party scripts from your lint task:

      gulp.task('lint', function () {
          var jshint = require('gulp-jshint');
      
          return gulp.src(['app/scripts/**/*.js', '!app/script/path/to/script/that/fails.js'])
              .pipe(jshint())
              .pipe(jshint.reporter('default'));
      }); 
      
    3. Put files which don't comply to the JSHint rules to another folder.

    I guess that you most likely won't have your own files JSHint compliant, so I'd suggest 1. for a quick try, but read a little into dependency management and linting ;-)