2016-07-13 19 views
0

Ich versuche eine Grunt-Aufgabe zu erstellen, die meine JS-Dateien minimiert und eine einzelne verkleinerte JS-Datei zurückgibt.Das Ausführen von minified in Grunt kann die Eigenschaft undefined nicht lesen

Das ist meine gruntfile.js Datei:

module.exports = function (grunt) { 

     // Project configuration. 
     grunt.initConfig({ 
      minified: { 
       files: { 
        src: [ 
        'js/*.js', 
        ], 
        dest: 'js/min/' 
       }, 
       options: { 
        allinone: true 
       } 
      }, 
     }); 

     grunt.loadNpmTasks('grunt-minified'); 
    }; 

Wenn ich laufe die Aufgabe, es funktioniert, aber es gibt auch einen Fehler.

> cmd.exe /c grunt -b "C:\Users\alucardu\documents\visual studio 2015\Projects\JS-demo\JS-demo" --gruntfile "C:\Users\alucardu\documents\visual studio 2015\Projects\JS-demo\JS-demo\Gruntfile.js" minified 
    Running "minified:files" (minified) task 
    Warning: Cannot read property 'yellow' of undefined Use --force to continue. 
    Process terminated with code 3. 
    Aborted due to warnings. 

Ich habe eine Suchaktion in meiner gesamten Lösung für "gelb" durchgeführt, aber es gibt keine Ergebnisse zurück. Auch wenn ich beide meine JS-Dateien, die minimiert werden, entleere, gibt es immer noch den Fehler zurück.

Weiß jemand, warum es diesen Fehler zurückgibt?

Antwort

0

Durch die

options: { 
    allinone: true 
} 

Die Warnung nicht mehr zeigte bis zu entfernen, aber es concat auch nicht die zusammen Dateien. Also habe ich eine weitere Aufgabe namens concat hinzugefügt. So, jetzt sieht meine Gruntfile so aus:

module.exports = function (grunt) { 

     // Project configuration. 
     grunt.initConfig({ 
      watch: { 
       scripts: { 
        files: ['js/*.js'], 
        tasks: ['concat', 'minified', 'uglify'], 
       }, 
      }, 
      concat: { 
       dist: { 
        src: ['js/*.js'], 
        dest: 'js/min/concat.js' 
       }, 
      }, 
      minified: { 
       files: { 
        src: ['js/min/concat.js'], 
        dest: 'js/min/minified.js' 
       }, 
      }, 
      uglify: { 
       my_target: { 
        files: { 
         'js/min/uglify.js': ['js/min/minified.jsconcat.js'] 
        } 
       } 
      }, 

     }); 

     grunt.loadNpmTasks('grunt-contrib-watch'); 
     grunt.loadNpmTasks('grunt-contrib-concat'); 
     grunt.loadNpmTasks('grunt-minified'); 
     grunt.loadNpmTasks('grunt-contrib-uglify'); 


    }; 

Und es scheint gut zu funktionieren.