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

Unable to configure hash after upgrading to 2.0 #55

Closed
kachkaev opened this issue Jan 2, 2019 · 2 comments
Closed

Unable to configure hash after upgrading to 2.0 #55

kachkaev opened this issue Jan 2, 2019 · 2 comments

Comments

@kachkaev
Copy link

kachkaev commented Jan 2, 2019

Hi again @cyrilwanner 👋

I'm curious how difficult would it be to customise hash, similar to how it used to work in v1. Back then my config looked like so, according to what file-loader accepts:

{ imagesName: "[name].[ext]?h=[sha512:hash:base64:4]" }

The trick with the hash formatting stopped working after upgrading next-optimized-images to v2, so my config had to become:

{ imagesName: "[name].[ext]?h=[hash]" }

Otherwise, the following error shows up:

Module build failed (from ../node_modules/url-loader/dist/cjs.js):
Error: Digest method not supported
    at new Hash (internal/crypto/hash.js:33:18)
    at Object.createHash (crypto.js:101:10)
    at getHashDigest (/path/to/project/node_modules/loader-utils/lib/getHashDigest.js:46:34)
    at url.replace (/path/to/project/node_modules/loader-utils/lib/interpolateName.js:96:11)
    at String.replace (<anonymous>)
    at Object.interpolateName (/path/to/project/node_modules/loader-utils/lib/interpolateName.js:93:8)
    at Object.loader (/path/to/project/node_modules/file-loader/dist/index.js:24:36)
    at Object.loader (/path/to/project/node_modules/url-loader/dist/index.js:76:19)

I'm wondering if hash could be made customisable again, which should help shorten asset paths if desired. WDYT?

@cyrilwanner
Copy link
Owner

Thanks again for your issue. I think this was a bug in the file-loader (or a combination with the file-loader and url-loader). At least that's the only thing which makes sense to me, as I just pass down your names to the url-/file-loader.
I just published another patch which updates file-loader to the latest version (should have read all Issues first 😅): v2.3.3

Can you please test this version in your project?
If you still get this error, please make sure you have file-loader version 3.0.1 (if you have it manually installed or another plugin is refering to an older version).

@kachkaev
Copy link
Author

Hi @cyrilwanner and thanks for looking into this issue despite being busy! I tried [email protected] but got the same error unfortunately. Looks like just ugrading file-loader is not enough – I've got the latest:

yarn why file-loader
...
=> Found "[email protected]"
info Reasons this module exists
   - "next-optimized-images" depends on it
   - Hoisted from "next-optimized-images#file-loader"
...
(no other versions installed)

UPD: Playing with various functions in the call stack, I noticed a bug in loader-utils and it turned out that it was already fixed: webpack/loader-utils#136. So upgrading the version of loader-utils in my yarn.lock file solved the problem 🎉

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