UNPKG

isomorphic-style-loader

Version:

CSS style loader for Webpack optimized for critical path CSS rendering and isomoprhic web apps

23 lines (20 loc) 1.85 kB
/*! Isomorphic Style Loader | MIT License | https://github.com/kriasoft/isomorphic-style-loader */ 'use strict'; module.exports = function loader() {}; module.exports.pitch = function pitch(request) { var _this = this; if (this.cacheable) { this.cacheable(); } var stringifyRequest = function stringifyRequest(req) { return JSON.stringify(_this.utils.contextify(_this.context, req)); }; var insertCss = require.resolve('./insertCss.js'); var _this$getOptions = this.getOptions(), getCss = _this$getOptions.getCss; getCss = typeof getCss === 'function' ? getCss : function (css) { return css; }; return "\n var getCss = " + getCss.toString() + ";\n var css = getCss(require(" + stringifyRequest("!!" + request) + "));\n var insertCss = require(" + stringifyRequest("!" + insertCss) + ");\n var content = typeof css === 'string' ? [[module.id, css, '']] : css;\n\n exports = module.exports = css.locals || {};\n exports._getContent = function() { return content; };\n exports._getCss = function() { return '' + css; };\n exports._insertCss = function(options) { return insertCss(content, options) };\n\n " + (this.hot ? "\n // Hot Module Replacement\n // https://webpack.github.io/docs/hot-module-replacement\n // Only activated in browser context\n if (module.hot && typeof window !== 'undefined' && window.document) {\n var removeCss = function() {};\n module.hot.accept(" + stringifyRequest("!!" + request) + ", function() {\n css = getCss(require(" + stringifyRequest("!!" + request) + "));\n content = typeof css === 'string' ? [[module.id, css, '']] : css;\n removeCss = insertCss(content, { replace: true });\n });\n module.hot.dispose(function() { removeCss(); });\n }\n " : '') + "\n "; }; //# sourceMappingURL=index.js.map