Images not found when doing a production build wit

2019-05-18 02:27发布

问题:

When I am trying to deploy my application in my prod the WAR do not have the images directory so i get my application deploy without any images.

What could be the problem?

回答1:

It looks like the cause of the problem is "gulp-imagemin", as a workaround remove this line:

.pipe(imagemin({optimizationLevel: 5, progressive: true, interlaced: true}))

from: gulpfile.js



回答2:

Your images must be in src/main/webapp/content/images to get minified and copied by gulp to target/www/content/images and then be copied at the root of you war in content/images by maven or gradle.



回答3:

If gulp-imagemin says it minified 0 images, it's often due to missing binaries needed in these node modules:

  • optipng
  • jpegtran
  • gifsicle

If you look eg. into node_modules/optipng-bin, you'll see that the optipng binary is missing (should be in a vendor subfolder).

They are not compiled during npm install, and it's completely silent :)

Installing the zlib1g-dev package fixed the issue on a fresh Debian 9 system.

I had to install build-base and zlib-dev https://github.com/imagemin/optipng-bin/issues/84

Generally speaking, you need several build tools on your system to build a JHipster prod package (make, g++ for scss, etc.).