Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

file-loader

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

file-loader - npm Package Compare versions

Comparing version 0.8.5 to 0.9.0

44

index.js

@@ -10,11 +10,45 @@ /*

if(!this.emitFile) throw new Error("emitFile is required from module system");
var query = loaderUtils.parseQuery(this.query);
var url = loaderUtils.interpolateName(this, query.name || "[hash].[ext]", {
context: query.context || this.options.context,
var configKey = query.config || "fileLoader";
var options = this.options[configKey] || {};
var config = {
publicPath: false,
name: "[hash].[ext]"
};
// options takes precedence over config
Object.keys(options).forEach(function(attr) {
config[attr] = options[attr];
});
// query takes precedence over config and options
Object.keys(query).forEach(function(attr) {
config[attr] = query[attr];
});
var url = loaderUtils.interpolateName(this, config.name, {
context: config.context || this.options.context,
content: content,
regExp: query.regExp
regExp: config.regExp
});
this.emitFile(url, content);
return "module.exports = __webpack_public_path__ + " + JSON.stringify(url) + ";";
var publicPath = "__webpack_public_path__ + " + JSON.stringify(url);
if (config.publicPath) {
// support functions as publicPath to generate them dynamically
publicPath = JSON.stringify(
typeof config.publicPath === "function"
? config.publicPath(url)
: config.publicPath + url
);
}
if (query.emitFile === undefined || query.emitFile) {
this.emitFile(url, content);
}
return "module.exports = " + publicPath + ";";
}
module.exports.raw = true;

2

package.json
{
"name": "file-loader",
"version": "0.8.5",
"version": "0.9.0",
"author": "Tobias Koppers @sokra",

@@ -5,0 +5,0 @@ "description": "file loader module for webpack",

@@ -16,2 +16,11 @@ # file loader for webpack

By default a file is emitted, however this can be disabled if required (e.g. for server
side packages).
``` javascript
var url = require("file?emitFile=false!./file.png");
// => returns the public url but does NOT emit a file
// => returns i. e. "/public-path/0dcbbaa701328a3c262cfd45869e351f.png"
```
## Filename templates

@@ -29,3 +38,3 @@

* `[path]` the path of the resource relative to the `context` query parameter or option.
* `[hash]` the hash or the content
* `[hash]` the hash of the content, `hex`-encoded `md5` by default
* `[<hashType>:hash:<digestType>:<length>]` optionally you can configure

@@ -64,4 +73,8 @@ * other `hashType`s, i. e. `sha1`, `md5`, `sha256`, `sha512`

## Installation
```npm install file-loader --save-dev```
## License
MIT (http://www.opensource.org/licenses/mit-license.php)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc