0.0.4 • Published 8 years ago

advanced-url-loader v0.0.4

Weekly downloads
6
License
MIT
Repository
github
Last release
8 years ago

Advanced url loader for Webpack

Based on url-loader

Works exactly like url-loader but allows to specify how encode specific MIME-type. For example for SVG there is no necessary to encode source in base64, because it works with raw content encoded with encodeURIComponent as well. It will decrease ~30% of content length and save browser resources for unpacking base64 string.

Configuration

For compatibility with url-loader advancedUrl option is used:

{
  module: {
    loaders: [
      {
        test: /\.(jpg|png|gif|svg)$/,
        loader: 'advanced-url?limit=10000'
      }
    ]
  },
  advancedUrl: {
    handlers: {
      'image/svg+xml': function (content) {
        return 'data:image/svg+xml,' + encodeURIComponent(content);
      }
    }
  }
}