OpenSourceWorkflow / generator-kickstart

[deprecated]: yeoman generator for website development
MIT License
10 stars 1 forks source link

BUG, running imagemin-task in a folder with parentheses #185

Closed stephanfriedrich closed 8 years ago

stephanfriedrich commented 8 years ago

In a Windows-Livesystem with an parentheses folder name, grunt imagemin copies the minified images in an wrong directory. See Imagemin-Bug.

This is an Bug from Imagemin 4, unfortunately the team from contrib-imagemin cant do anything because they use vinyl-fs which needs imagemin4.

stephanfriedrich commented 8 years ago

I created an cheesy workaround. Maybe it helps someone.

here we run imagemin-cli (or imagemin-newer) to imagemin-temporary-directory, copy everything with grunt-copy (in my case for crossOS reasons) into the origin-image-source, and remove imagemin-temporary-directory.

update package.json

...
  "devDependencies": {
    "grunt-contrib-copy": "^0.6.0",
    "grunt-shell": "^1.3.0",
    "imagemin": "latest",
    "imagemin-newer": "^1.0.1",
  },
  "scripts": {
    "imagemin_script_1": "imagemin-newer <source-dir-1> <destination-dir-temp1> -d".
    "imagemin_script_2": "imagemin-newer <source-dir-2> <destination-dir-temp2> -d"
  },
...

update gruntfile.js

...
    shell: {
      options: {
        stderr: false
      },
      imagemin: {
        command: [
          'npm run imagemin_script_1'
          'npm run imagemin_script_2'
        ].join('&&')
      },
      removeImageminTmp: {
        command:  [
          'rm -rf <source-dir-1>'
          'rm -rf <source-dir-2>'
        ].join('&&')
      }
    },
    copy: {
      imageminCssImages: {
        files: [{
          expand: true,
          flatten: true,
          src: ''source-dir-temp1/**/*.{png,gif,jpg,svg,ico}',
          dest: 'build/assets/img'
        }]
      },
      imageminHtmlImages: {
        files: [{
          expand: true,
          flatten: true,
          src: ''source-dir-temp2/**/*.{png,gif,jpg,svg,ico}',
          dest: 'build/img'
        }]
      }
    },
...
...
  grunt.loadNpmTasks('grunt-shell');
  grunt.loadNpmTasks('grunt-contrib-copy');

  grunt.registerTask('test', [
    'shell:imagemin',
    'copy',
    'shell:removeImageminTmp',
  ]);
...
stephanfriedrich commented 8 years ago

i write these ticket because of documentation aspects.