image-size-loader icon indicating copy to clipboard operation
image-size-loader copied to clipboard

Getting size data without emitting files

Open rhys-vdw opened this issue 9 years ago • 5 comments

Is it possible use this loader without outputting files?

rhys-vdw avatar Jan 13 '16 16:01 rhys-vdw

Why ?

I'm not clear about your use-case. You can simply ignore the file that's outputted if that's an option.

https://github.com/boopathi/image-size-loader/blob/4fa307fd391f0d262f6dfe1c14d88b458081b71b/index.js#L46

This is the code that's responsible for the copying the image. PR welcome :).

boopathi avatar Jan 14 '16 05:01 boopathi

Well, I'm new to the custom loader thing, so maybe I'm doing something unusual/wrong. Basically I'm getting the dimensions of images that are sprites in a game. I just check the images so I know how to scale the plane that I'm applying them to.

In my case I'm still just requesting them via ajax from their original folder. Would it to be more normal to read from /src and move them to an out folder from which they can be required?

rhys-vdw avatar Jan 14 '16 07:01 rhys-vdw

I need this feature too. The reason is: I'm using url-loader to get data-uri images. So I do not need to emit files, because they are inlined.

P.S. @boopathi Probably it would be cool if this loader will work on top of url-laoder/file-loader to reuse the abilities of that loaders.

There is one more thing. What are you thinking about this hack?

var foo = new String('foo/bar.gif');

Object.assign(foo, {
    width: 123
});

console.log(foo + '', foo.width)

SleepWalker avatar Sep 22 '16 04:09 SleepWalker

@SleepWalker, @rhys-vdw

If you still need this, I've forked this loader to one which doesn't output the file: https://github.com/tremby/image-dimensions-loader (also published on NPM as image-dimensions-loader).

tremby avatar Dec 20 '17 05:12 tremby

@boopathi: assuming you're not going to add an option to do something similar, a link from your readme to my fork for others looking for this feature would be appreciated.

tremby avatar Dec 20 '17 05:12 tremby