/usr/lib/nodejs/file-loader/index.js is in node-file-loader 0.11.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | /*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
var path = require("path");
var loaderUtils = require("loader-utils");
module.exports = function(content) {
this.cacheable && this.cacheable();
if(!this.emitFile) throw new Error("emitFile is required from module system");
var query = loaderUtils.getOptions(this) || {};
var configKey = query.config || "fileLoader";
var options = this.options[configKey] || {};
var config = {
publicPath: undefined,
useRelativePath: 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 context = config.context || this.options.context;
var url = loaderUtils.interpolateName(this, config.name, {
context: context,
content: content,
regExp: config.regExp
});
var outputPath = "";
var filePath = this.resourcePath;
if (config.useRelativePath) {
var issuerContext = this._module && this._module.issuer && this._module.issuer.context || context;
var relativeUrl = issuerContext && path.relative(issuerContext, filePath).split(path.sep).join("/");
var relativePath = relativeUrl && path.dirname(relativeUrl) + "/";
if (~relativePath.indexOf("../")) {
outputPath = path.posix.join(outputPath, relativePath, url);
} else {
outputPath = relativePath + url;
}
url = relativePath + url;
} else if (config.outputPath) {
// support functions as outputPath to generate them dynamically
outputPath = (
typeof config.outputPath === "function"
? config.outputPath(url)
: config.outputPath + url
);
url = outputPath;
} else {
outputPath = url;
}
var publicPath = "__webpack_public_path__ + " + JSON.stringify(url);
if (config.publicPath !== undefined) {
// 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(outputPath, content);
}
return "module.exports = " + publicPath + ";";
};
module.exports.raw = true;
|