Skip to content
This repository has been archived by the owner on Apr 28, 2018. It is now read-only.

kisenka/advanced-url-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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);
      }
    }
  }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published