itgalaxy / imagemin-power-cli

Optimize (compress) images with power using imagemin :muscle:
MIT License
13 stars 0 forks source link

omit source folder #99

Open landsman opened 6 years ago

landsman commented 6 years ago

Hi guys,

I have problem with recursive saving. I want omit source folder of the tree - in my case front folder.

Using:

{
  "scripts": {
    "postinstall": "npm run build",
    "build": "npm run sass && npm run autoprefixer && npm run images",
    "sass": "node-sass -r -x --output-style compressed ./front/sass/ -o ./public/dist/css/",
    "watch": "onchange './front/sass/*' -- npm run build",
    "autoprefixer": "postcss -u autoprefixer --autoprefixer.browsers '> 5%, ie 9' -r ./public/dist/*",
    "images": "imagemin-power -rvd ./ front/images/**/* --out-dir=public/dist/images"
  },
  "devDependencies": {
    "autoprefixer": "^8.5.0",
    "imagemin-power-cli": "^3.0.0",
    "node-sass": "^4.9.0",
    "onchange": "^4.0.0",
    "postcss-cli": "^5.0.0"
  }
}

CLI output:

$ npm run images

> report@0.0.1 images /Users/michal.landsman/localhost/pp/report
> imagemin-power -rvd ./ front/images/**/* --out-dir=public/dist/images

✔ Minifying image "front/images/email/footer.png" (1 of 5) - saved 361 B - 59.5%...
✔ Minifying image "front/images/venue_report/logo_picto.svg" (2 of 5) - saved 36 B - 6.5%...
✔ Minifying image "front/images/email/company_logo.png" (3 of 5) - saved 83 B - 2.2%...
✔ Minifying image "front/images/venue_report/company_logo_white.png" (4 of 5) - saved 83 B - 2.2%...
✔ Minifying image "front/images/email/frantisek.png" (5 of 5) - already optimized...
ℹ Successfully compressed images: 5. Unsuccessfully compressed images: 0. Total images: 5. Total images size: 52.6 kB. Total saved size: 563 B - 1.0704032549384945%. 

Result tree folders:

front
├── images
│   ├── email
│   │   ├── company_logo.png
│   │   ├── footer.png
│   │   └── frantisek.png
│   └── venue_report
│       ├── company_logo_white.png
│       └── logo_picto.svg
public
├── dist
│   └── images
│       └── front
│           └── images
│               ├── email
│               │   ├── company_logo.png
│               │   ├── footer.png
│               │   └── frantisek.png
│               └── venue_report
│                   ├── company_logo_white.png
│                   └── logo_picto.svg

Is that possible please?

EDIT: This setup works for me: imagemin-power -rvd ./front/ images/**/* --out-dir=public/dist/ But I think that setup working directory is not expected by default, right?