file-loader
Advanced tools
Comparing version 0.8.1 to 0.8.2
{ | ||
"name": "file-loader", | ||
"version": "0.8.1", | ||
"author": "Tobias Koppers @sokra", | ||
"description": "file loader module for webpack", | ||
"dependencies": { | ||
"loader-utils": "~0.2.5" | ||
}, | ||
"devDependencies": { | ||
"should": "~4.0.4", | ||
"mocha": "~1.21.3" | ||
}, | ||
"scripts": { | ||
"test": "mocha -R spec" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git@github.com:webpack/file-loader.git" | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "http://www.opensource.org/licenses/mit-license.php" | ||
} | ||
] | ||
"name": "file-loader", | ||
"version": "0.8.2", | ||
"author": "Tobias Koppers @sokra", | ||
"description": "file loader module for webpack", | ||
"files": [ | ||
"index.js" | ||
], | ||
"dependencies": { | ||
"loader-utils": "~0.2.5" | ||
}, | ||
"devDependencies": { | ||
"should": "~4.0.4", | ||
"mocha": "~1.21.3" | ||
}, | ||
"scripts": { | ||
"test": "mocha -R spec" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git@github.com:webpack/file-loader.git" | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "http://www.opensource.org/licenses/mit-license.php" | ||
} | ||
] | ||
} |
@@ -13,6 +13,14 @@ # file loader for webpack | ||
By default the filename is the md5 hash of the file and the extension of the required resource is appended. | ||
By default the filename of the resulting file is the MD5 hash of the file's contents | ||
with the original extension of the required resource. | ||
You can configure a custom filename template for your file (query param `name`). | ||
## Filename templates | ||
You can configure a custom filename template for your file using the query | ||
parameter `name`. For instance, to copy a file from your `context` directory | ||
into the output directory retaining the full directory structure, you might | ||
use `?name=[path][name].[ext]`. | ||
### Filename template placeholders | ||
* `[ext]` the extension of the resource | ||
@@ -28,3 +36,3 @@ * `[name]` the basename of the resource | ||
Examples | ||
## Examples | ||
@@ -45,3 +53,3 @@ ``` javascript | ||
require("file?name=img-[sha512:base64:7].[ext]!./image.jpg"); | ||
require("file?name=img-[sha512:hash:base64:7].[ext]!./image.jpg"); | ||
// => img-VqzT5ZC.jpg | ||
@@ -53,3 +61,3 @@ // use custom name, sha512 hash instead of md5 and with only 7 chars of base64 | ||
require("file?[path][name].[ext]?[hash]!./dir/file.png") | ||
require("file?name=[path][name].[ext]?[hash]!./dir/file.png") | ||
// => dir/file.png?e43b20c069c4a01867c31e98cbce33c9 | ||
@@ -56,0 +64,0 @@ ``` |
65
3587
3
18