JSPM

image-size-loader

0.6.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 16
  • Score
    100M100P100Q64146F
  • License Apache-2.0

image size loader module for webpack

Package Exports

  • image-size-loader

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (image-size-loader) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

image size loader for webpack

Usage

Documentation: Using loaders

var image = require("image-size!./file.png");
// => returns js object: i.e. { width: 400, height: 300, type: "png", src: "file.png" }

Options

Output filename

You can use the placeholders specified here -

  • [ext] the extension of the resource
  • [name] the basename of the resource
  • [path] the path of the resource relative to the context query parameter or option.
  • [hash] the hash of options.content (Buffer) (by default it's the hex digest of the md5 hash)
  • [<hashType>#️⃣<digestType>:<length>] optionally one can configure
    • other hashTypes, i. e. sha1, md5, sha256, sha512
    • other digestTypes, i. e. hex, base26, base32, base36, base49, base52, base58, base62, base64
    • and length the length in chars
  • [N] the N-th match obtained from matching the current file name against options.regExp

Source: https://github.com/webpack/loader-utils#interpolatename

config.output.imageFilename

// webpack.config.js
module.exports = {
    output: {
        imageFilename: '[name]-[hash].[ext]'
    }
}

query param

var image = require('image-size!./file.png?name=[hash].[ext]');

config.output.publicPath

The path/URL that gets prepended to the imageFilename - https://github.com/webpack/docs/wiki/configuration#outputpublicpath

License

MIT (http://www.opensource.org/licenses/mit-license.php)