2016-04-12 6 views
0

最適化されていない画像を移動しません。圧縮されると、imagesフォルダーに保存されます。これらは、プロジェクトで使用するものです。イサキimageminは、私はちょうど私が働いているプロジェクトでこれを気づいた

いくつかの画像には最適化が必要なく、ソースフォルダに留まり、imagesに移動していないことがわかりましたが、今では画像が欠落していて、どんなものなのか正確に知ることすらできない。

これはバグですか、何か不足していますか?

私の構成はかなり単純です:

imagemin: { 
    dynamic: { 
     files: [{ 
      expand: true, // Enable dynamic expansion 
      cwd: '_src/images/', // source images (not compressed) 
      src: ['**/*.{png,jpg,gif,svg}'], // Actual patterns to match 
      dest: '_dev/images/' // Destination of compressed files 
     }] 
    } 
}, //end imagemin 

は、どのように私はとにかくdistのためにソースからの私の最適化されていない画像を移動するのですか?

答えて

0

コピータスクを実行した直後に、最適化されていないすべての画像を移動することができます。

すでにdestにある圧縮イメージを上書きしないようにするフィルタがあります。

copy: { 
    unoptimizedImage: { 
    expand: true, 
    cwd: '_src/images/', 
    src: ['**/*.{png,jpg,gif,svg}'], 
    dest: '_dev/images/' 

    // Copy if file does not exist. 
    filter: function (filepath) { 
     // NPM load file path module. 
     var path = require('path'); 

     // Construct the destination file path. 
     var dest = path.join(
      grunt.config('copy.main.dest'), 
      path.basename(filepath) 
     ); 

     // Return false if the file exists. 
     return !(grunt.file.exists(dest)); 
    }, 
}, 
}, 
関連する問題