2012-04-07 05:06:57 +04:00
|
|
|
/*
|
|
|
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
|
|
Author Tobias Koppers @sokra
|
|
|
|
*/
|
2014-10-20 20:22:46 +04:00
|
|
|
var loaderUtils = require("loader-utils"),
|
|
|
|
path = require("path");
|
2013-01-28 18:06:19 +04:00
|
|
|
module.exports = function() {};
|
|
|
|
module.exports.pitch = function(remainingRequest) {
|
2012-05-21 02:07:19 +04:00
|
|
|
this.cacheable && this.cacheable();
|
2014-10-20 20:22:46 +04:00
|
|
|
var query = loaderUtils.parseQuery(this.query);
|
2014-08-14 13:12:19 +04:00
|
|
|
return [
|
|
|
|
"// style-loader: Adds some css to the DOM by adding a <style> tag",
|
2014-09-08 00:23:54 +04:00
|
|
|
"",
|
|
|
|
"// load the styles",
|
2015-04-10 00:46:55 +03:00
|
|
|
"var content = require(" + loaderUtils.stringifyRequest(this, "!!" + remainingRequest) + ");",
|
2014-09-30 01:22:41 +04:00
|
|
|
"if(typeof content === 'string') content = [[module.id, content, '']];",
|
2014-09-08 00:23:54 +04:00
|
|
|
"// add the styles to the DOM",
|
2015-04-10 00:46:55 +03:00
|
|
|
"var update = require(" + loaderUtils.stringifyRequest(this, "!" + path.join(__dirname, "addStyles.js")) + ")(content, " + JSON.stringify(query) + ");",
|
2014-08-14 13:12:19 +04:00
|
|
|
"// Hot Module Replacement",
|
|
|
|
"if(module.hot) {",
|
2014-09-08 00:23:54 +04:00
|
|
|
" // When the styles change, update the <style> tags",
|
2015-04-10 00:46:55 +03:00
|
|
|
" module.hot.accept(" + loaderUtils.stringifyRequest(this, "!!" + remainingRequest) + ", function() {",
|
|
|
|
" var newContent = require(" + loaderUtils.stringifyRequest(this, "!!" + remainingRequest) + ");",
|
2014-12-27 22:32:33 +03:00
|
|
|
" if(typeof newContent === 'string') newContent = [[module.id, newContent, '']];",
|
2014-09-08 00:23:54 +04:00
|
|
|
" update(newContent);",
|
|
|
|
" });",
|
|
|
|
" // When the module is disposed, remove the <style> tags",
|
|
|
|
" module.hot.dispose(function() { update(); });",
|
2014-08-14 13:12:19 +04:00
|
|
|
"}"
|
|
|
|
].join("\n");
|
2013-01-28 18:06:19 +04:00
|
|
|
};
|