critical-style-loader
Advanced tools
Comparing version 2.0.0-beta.13 to 2.0.0-beta.14
@@ -8,4 +8,8 @@ "use strict"; | ||
var _hashCode = _interopRequireDefault(require("./hashCode")); | ||
var _constants = require("./constants"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } | ||
@@ -44,7 +48,8 @@ | ||
var _module = _slicedToArray(module, 2), | ||
id = _module[0], | ||
css = _module[1]; | ||
if (!_this.map[id]) { | ||
_this.map[id] = css; | ||
var key = (0, _hashCode.default)(css); | ||
if (!_this.map[key]) { | ||
_this.map[key] = css; | ||
} | ||
@@ -51,0 +56,0 @@ }); |
@@ -29,3 +29,3 @@ "use strict"; | ||
var path = loaderUtils.stringifyRequest(this, "!!".concat(request)); | ||
return "\n let content = require(".concat(path, ");\n\n if (window && document) {\n if (window.").concat(GLOBAL_HOOK, " && window.").concat(GLOBAL_HOOK, "[module.id]) {\n module.exports = '';\n } else {\n module.exports = content;\n }\n } else {\n if (typeof content === 'string') {\n content = [[module.id, content, '']];\n }\n\n // Export CSS Modules\n if (content.locals) {\n module.exports = content.locals;\n }\n\n // Provide getter for raw CSS.\n module.exports.getCss = function() {\n return content;\n };\n }\n "); | ||
return "\n var content = require(".concat(path, ");\n var hashCode = require('critical-style-loader/lib/hashCode.js');\n\n // function hashCode(hashString) {\n // var hash = 0;\n // var chr;\n\n // for (var i = 0; i < hashString.length; i += 1) {\n // chr = hashString.charCodeAt(i);\n // hash = (hash << 5) - hash + chr;\n // hash |= 0; // Convert to 32bit integer\n // }\n\n // return hash;\n // }\n\n if (\n 'undefined' !== typeof window &&\n 'undefined' !== typeof document\n ) {\n var preRendered = content.some(function(module) {\n var css = module[1];\n var id = hashCode(css);\n\n if (window.").concat(GLOBAL_HOOK, " && window.").concat(GLOBAL_HOOK, "[id]) {\n console.log('prerendered!', css, id);\n return true;\n }\n\n return false;\n });\n\n if (preRendered) {\n module.exports = '/* CSS output skipped for ' +\n module.id +\n ' prerendered server-side */';\n } else {\n module.exports = content;\n }\n } else {\n if (typeof content === 'string') {\n content = [[module.id, content, '']];\n }\n\n // Export CSS Modules\n if (content.locals) {\n module.exports = content.locals;\n }\n\n // Provide getter for raw CSS.\n module.exports.getCss = function() {\n return content;\n };\n }\n "); | ||
}; |
{ | ||
"name": "critical-style-loader", | ||
"version": "2.0.0-beta.13", | ||
"version": "2.0.0-beta.14", | ||
"description": "A webpack loader for rendering critical path CSS on the server with utilities to avoid client side style-loader style duplications.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
13186
164