Skip to content

mariusbalcytis/extract-file-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Extract file loader for webpack

Reason for this module:

  • assets-webpack-plugin generates a manifest of emitted files for each chunk
  • file-loader emits files, but they are not added to the chunk files
  • this loader is used as a proxy to include this emitted file in the chunk so it's available in generated manifest

Install

# for webpack 4
npm install --save-dev extract-file-loader
# for webpack 3
npm install --save-dev extract-file-loader@0.2.0
# for webpack 1, 2
npm install --save-dev extract-file-loader@0.1.0

Usage

require('extract-file?q=file%3Fname=[name].[hash].[ext]%21image.png!');
//                       %3F = ?                    %21 = !

Why did you put asset in the query string?!

Asset to require internally is provided via q query string parameter.

This is to avoid collisions with rules in your configuration file, where you configure loaders by their extensions.

Keep in mind that you have to fully URL-encode the asset as webpack will not parse it correctly if you don't (there cannot be any literal ! inside the query)

Example configuration

See example configuration in test directory.

Test is functional - it checks if that configuration produces manifest with correct png file entry.

Use cases

Use this for requiring binary files (like images) as entry points.

This module is to be used with some pre/post-processing, as by default this loader still produces javascript file - path to asset is only added in the manifest.

About

Loader and plugin for webpack to add proxied asset as a chunk file

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •