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

Cache loader? #52

Closed
strarsis opened this issue Jan 22, 2018 · 9 comments
Closed

Cache loader? #52

strarsis opened this issue Jan 22, 2018 · 9 comments

Comments

@strarsis
Copy link

strarsis commented Jan 22, 2018

Does it make sense using the webpack cache-loader with this responsive-loader for speeding up builds?

@jstcki
Copy link
Contributor

jstcki commented Jan 23, 2018

I haven't tried but I think it makes sense.

@daniel100097
Copy link

daniel100097 commented Apr 19, 2018

{
    test: /\.(jpe?g|png)$/i,
    use: [{
        loader: "cache-loader",
    }, {
        loader: "url-loader",
        options: {
            adapter: require("responsive-loader/jimp"),
            fallback: "responsive-loader",
            limit: 8192,
            sizes: isProd() ? [720, 1024, 1920] : [1920],
            format: "png",
        },
    }],

}

@strarsis
Copy link
Author

strarsis commented Jan 2, 2020

@daniel100097: Thanks, but when I try that config no resized image files are emitted anymore.
sharp is used instead of jimp in this setup, maybe this causes the issue?

@DotIN13
Copy link

DotIN13 commented Mar 9, 2021

After doing a bit experiment, I figured that the deprecated cache-loader was substituted by the cache option, documented on Caching | webpackwebpack.js.org › guides › caching. The images cached will not be regenerated between builds.

I managed to lower my rebuild time from 160s to 0.4s with the following setting:

module.exports = {
  ...
   cache: {
        type: "filesystem",
        cacheDirectory: path.resolve(__dirname, '.webpack-cache'),
    }
}

@strarsis
Copy link
Author

@DotIN13: Awesome! Thanks.

@slorber
Copy link

slorber commented Apr 2, 2021

@DotIN13 are the resized images cached in the node_modules/.cache/webpack folder too as a .pack file?

@DotIN13
Copy link

DotIN13 commented Apr 3, 2021

@DotIN13 are the resized images cached in the node_modules/.cache/webpack folder too as a .pack file?

As I see it, the cache config I posted does not involve a node_modules/.cache directory. Looks like the cache generated were all stored in .webpack-cache dir.

@slorber
Copy link

slorber commented Apr 3, 2021

@DotIN13 it's the default cache location.

Do to reword my question: do you see images in .webpack-cache? Or do you fthink images are in a pack file?

@DotIN13
Copy link

DotIN13 commented Apr 3, 2021

@DotIN13 it's the default cache location.

Do to reword my question: do you see images in .webpack-cache? Or do you fthink images are in a pack file?

Okay, yes, image caches were bundled in .pack files by webpack. And as webpack isn't regenerating any new images during rebuilds, I suppose that the resized images were included in those .pack files.

@dazuaz dazuaz closed this as completed Jun 9, 2022
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

6 participants