Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working on FreeBSD #41

Open
moroz opened this issue Aug 21, 2019 · 4 comments
Open

Not working on FreeBSD #41

moroz opened this issue Aug 21, 2019 · 4 comments

Comments

@moroz
Copy link

moroz commented Aug 21, 2019

Hello,
I am trying to build a Webpack bundle for my Phoenix project, and for research I decided to give it a shot on FreeBSD.
My application repo is on Gitlab, the webpack bundle is in assets/ directory.
I have installed mozjpeg from BSD ports, and there is a cjpeg binary available:

$ cjpeg -V
Independent JPEG Group's CJPEG, version 8d  15-Jan-2012
Copyright (C) 2012, Thomas G. Lane, Guido Vollbeding

I know that mozjpeg is available in some way, because image-webpack-loader can use it and produces almost the same images as on my OSX machine. However, image-webpack-loader seems to only work with images that are imported in CSS, such as with background-image, and it doesn't optimise images copied over using CopyWebpackPlugin. I can't get these settings to run in Webpack on FreeBSD (Linux and OSX are fine):

  plugins: [
    new MiniCssExtractPlugin({ filename: "../css/app.css" }),
    new CopyWebpackPlugin([{ from: "static/", to: "../" }]),
    new ImageminPlugin({
      test: /\.(jpe?g|png|gif|svg)$/i,
      plugins: [
        imageminMozjpeg({
          quality: 80,
          progressive: true
        })
      ]
    })
  ]

The first error is that there is no cjpeg binary in vendor/:

freebsd:~/dw-taiwan/assets$ yarn deploy
yarn run v1.17.3
$ webpack --mode production
Error: spawn /usr/home/deploy/dw-taiwan/assets/node_modules/mozjpeg/vendor/cjpeg ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
    at onErrorNT (internal/child_process.js:456:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:9)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

When I create a symbolic link to the cjpeg binary installed in the system, it's no good either:

freebsd:~/dw-taiwan/assets$ ln -s /usr/local/bin/cjpeg /home/deploy/dw-taiwan/assets/node_modules/mozjpeg/vendor/cjpeg                       1
freebsd:~/dw-taiwan/assets$ yarn deploy
yarn run v1.17.3
$ webpack --mode production
Error: Unrecognized input file format --- perhaps you need -targa

    at /usr/home/deploy/dw-taiwan/assets/node_modules/execa/index.js:231:11
    at processTicksAndRejections (internal/process/task_queues.js:89:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Any suggestions on how this could be solved? I am really curious about FreeBSD and I hope I could help fix this problem.
Best regards,
KM

@frossi85
Copy link

frossi85 commented Jun 1, 2020

@moroz Did you find any solution?

@moroz
Copy link
Author

moroz commented Jun 12, 2020

@frossi85 I think at the time I just left the images as is, without compression. Another quick and dirty workaround would be building assets in a continuous integration environment like CodeBuild, i.e. on Linux...

@frossi85
Copy link

@moroz thanks for answering. My case is not exactly like yours I am trying to optimize images that where uploaded by my app users but having similar issues

@moroz
Copy link
Author

moroz commented Jun 15, 2020

Is imagemagick an option? I think I had it working on FreeBSD under Elixir.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants