2013-08-08 5 views
7

मैं रूप में की जरूरत ही कम करें फ़ाइल के लिए मेरी बदसूरत बनाना कार्य के विन्यास को बदलने की जरूरत है (जैसा कि यहाँ JSHint कार्य के लिए समझाया, https://github.com/gruntjs/grunt-contrib-watch#compiling-files-as-needed)कार्य के विन्यास बदसूरत करना बदलें गतिशील

संशोधन JSHint कार्य के लिए अच्छी तरह से काम करता है लेकिन बदसूरत करना के लिए नहीं, मुझे लगता है कि समस्या संपत्ति पथ है ...

किसी भी मदद की सराहना की जाएगी;)

यहाँ मेरी Gruntfile.js है:

module.exports = function (grunt) { 
    grunt.initConfig({ 

     // define source files and their destinations 
     jshint: { 
      all: ['dev/**/*.js'], 
     }, 
     uglify: { 
      dynamic_mappings: { 
       // Grunt will search for "**/*.js" under "dev/" when the "minify" task 
       // runs and build the appropriate src-dest file mappings then, so you 
       // don't need to update the Gruntfile when files are added or removed. 
      files: [{ 
        expand: true,  // Enable dynamic expansion. 
        cwd: 'dev/',  // Src matches are relative to this path. 
        src: ['**/*.js'], // Actual pattern(s) to match. 
        dest: 'build', // Destination path prefix. 
        ext: '.min.js', // Dest filepaths will have this extension. 
       }, 
       ], 
      } 
     } 
     watch: { 
     options: { spawn: false }, 
      js: { files: 'dev/**/*.js', tasks: [ 'uglify' ] }, 
     } 
    }); 

    // load plugins 
    grunt.loadNpmTasks('grunt-contrib-watch'); 
    grunt.loadNpmTasks('grunt-contrib-uglify'); 
    grunt.loadNpmTasks('grunt-contrib-jshint'); 

    // default task 
    grunt.registerTask('default', [ 'watch' ]); 

    grunt.event.on('watch', function(action, filepath) { 
     grunt.config(['jshint', 'all'], filepath); 
     grunt.config('uglify.dynamic_mappings.files', [{src: filepath }]); 
    }); 

}; 
+1

मैंने यह कोशिश नहीं की है, लेकिन यह संभव है कि फाइल कॉन्फ़िगरेशन कथन पूरी तरह से आपकी फाइल कॉन्फ़िगरेशन को प्रतिस्थापित कर रहा हो। क्या आपने uglify config को संशोधित करते समय सभी विशेषताओं (विस्तृत, cwd, आदि ...) प्रदान करने का प्रयास किया है? – dc5

+0

वह समाधान था! बहुत बहुत धन्यवाद। – Fab

उत्तर

8

लाइन

grunt.config('uglify.dynamic_mappings.files', [{src: filepath }]); 

पूरी तरह से uglify.dynamic_mappings.files

के लिए मूल विन्यास की जगह है

इसके बजाय कोशिश नया स्रोत के साथ-साथ अन्य मूल मापदंडों सहित: filepath

0

पहले से ही कम करें नहीं कैसे

uglify:  { 
     onlyScripts: { 
     files: [{ 
      dest: '<%= yeoman.dist %>/scripts/scripts.js', 
      src: ['.tmp/concat/scripts/scripts.js'] 
     }] 
     } 
    } 

इसके अलावा Yeoman में प्रत्येक "घुरघुराना निर्माण" पर न्यूनतम किया गया, अब सूरत बिगाड़ना से अपने vendor.js कॉपी नहीं करेंगे अस्थायी फ़ोल्डर है, तो "vendorJS" अनुभाग जोड़ें "प्रतिलिपि" कार्य करने के लिए:

copy: 
     //... 
     vendorJS: { 
     expand: true, 
     cwd: '.tmp/concat/scripts/', 
     dest: '<%= yeoman.dist %>/scripts/', 
     src: 'vendor.js' 
     } 

फिर, "निर्माण" कार्य में, 'onlyScripts' के लिए बदसूरत करना का लक्ष्य निर्धारित किया है और कॉपी vendor.js:

grunt.registerTask('build', [ 
    'jshint', 
    'clean:dist', 
    //'wiredep', 
    // ... 
    'useminPrepare', 
    //'concurrent:dist', 
    'autoprefixer', 
    'concat', 
    'ngAnnotate', 
    'copy:dist', 
    'cssmin', 
    'uglify:onlyScripts', 
    'copy:vendorJS', 
    // ... 
    ]); 

http://eugenioz.blogspot.in/2014/08/how-to-not-minify-already-minified-on.html

संबंधित मुद्दे