forked from webpack-contrib/file-loader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (32 loc) · 1.06 KB
/
index.js
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
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra and UFO ufoqhmdt@gmail.com
*/
var loaderUtils = require("loader-utils");
module.exports = function(content) {
'use strict';
var exportPath = '';
this.cacheable && this.cacheable();
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,
content: content,
regExp: query.regExp
});
if (query.relativePath) {
var relativePath =loaderUtils.interpolateName(this, query.relativePath || "[hash].[ext]", {
context: query.context || this.options.context,
content: content,
regExp: query.regExp
});
exportPath = JSON.stringify(relativePath);
} else {
exportPath = JSON.stringify(url);
}
this.emitFile(url, content);
return "module.exports = __webpack_public_path__ + " + exportPath + ";";
};
module.exports.raw = true;