UNPKG

css-sprite-loader

Version:

A webpack loader to convert png into sprite image

1 lines 11.6 kB
!function(e){var n={};function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var i in e)t.d(r,i,function(n){return e[n]}.bind(null,i));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="dest/",t(t.s=2)}([function(e,n,t){e.exports=t.p+"43aac074657a57fae8d4a159ea6bee8c.png"},function(e,n,t){e.exports=t.p+"df628f476db5a59bc37c58554453dbc5.png"},function(e,n,t){"use strict";t.r(n);t(3)},function(e,n,t){var r=t(4);"string"==typeof r&&(r=[[e.i,r,""]]);var i={transform:void 0};t(7)(r,i);r.locals&&(e.exports=r.locals)},function(e,n,t){var r=t(5);(e.exports=t(6)(!1)).push([e.i,"body {\n margin: 0;\n}\n\n.part {\n display: inline-block;\n width: 50%;\n}\n\n.source.simple {\n height: 200px;\n background: url("+r(t(0))+") no-repeat;\n}\n.sprite.simple {\n height: 200px;\n background: url('dest/sprite.png?e5cf95daa8d2c40e290009620b13fba3') left top no-repeat;\n}\n\n.source.no-width {\n height: 200px;\n background: url("+r(t(0))+") no-repeat;\n}\n\n@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 2dppx) {\n .source.no-width {\n background: url("+r(t(1))+") no-repeat;\n }\n}\n\n.source.no-width {\n background: -webkit-image-set(url("+r(t(0))+") 1x, url("+r(t(1))+") 2x) no-repeat;\n}\n.sprite.no-width {\n height: 200px;\n background: url('dest/sprite.png?e5cf95daa8d2c40e290009620b13fba3') left top no-repeat;\n}\n@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 2dppx) {\n .sprite.no-width {\n background: url('dest/sprite@2x.png?ef1bfc0e8cecdc1d49aaebde45d99b60') left top / 128px 128px no-repeat;\n }\n}\n\n.source.background-size {\n height: 200px;\n background: url("+r(t(0))+") left center / 50% no-repeat;\n}\n\n@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 2dppx) {\n .source.background-size {\n background: url("+r(t(1))+") left center / 50% no-repeat;\n }\n}\n\n.source.background-size {\n background: -webkit-image-set(url("+r(t(0))+") 1x, url("+r(t(1))+") 2x) left / 50% no-repeat;\n}\n.sprite.background-size {\n height: 200px;\n background: url('dest/sprite.png?e5cf95daa8d2c40e290009620b13fba3') left top / 64px 64px no-repeat;\n}\n@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 2dppx) {\n .sprite.background-size {\n background: url('dest/sprite@2x.png?ef1bfc0e8cecdc1d49aaebde45d99b60') left top / 64px 64px no-repeat;\n }\n}\n\n/* .source.image-set-prefix {\n width: 128px;\n height: 128px;\n background: -webkit-image-set(url('../../fixtures/images/retina/angry-birds@2x.png') 2x);\n}\n.sprite.image-set-prefix {\n width: 128px;\n height: 128px;\n background: -webkit-image-set(url('../../fixtures/images/retina/angry-birds@2x.png?sprite') 2x);\n}\n\n.source.image-set-fallback {\n width: 128px;\n height: 128px;\n background: url('../../fixtures/images/retina/angry-birds.png');\n background: -webkit-image-set(url('../../fixtures/images/retina/angry-birds.png') 1x, url('../../fixtures/images/retina/angry-birds@2x.png') 2x);\n}\n.sprite.image-set-fallback {\n width: 128px;\n height: 128px;\n background: url('../../fixtures/images/retina/angry-birds.png?sprite');\n background: -webkit-image-set(url('../../fixtures/images/retina/angry-birds.png?sprite') 1x, url('../../fixtures/images/retina/angry-birds@2x.png?sprite') 2x);\n}\n\n.source.image-set-and-other-things {\n width: 100px;\n height: 150px;\n background: url('../../fixtures/images/retina/angry-birds.png');\n background: -webkit-image-set(url('../../fixtures/images/retina/angry-birds.png') 1x, url('../../fixtures/images/retina/angry-birds@2x.png') 2x);\n background-size: 120%;\n background-position: 30px 20px;\n background-repeat: no-repeat;\n}\n.sprite.image-set-and-other-things {\n width: 100px;\n height: 150px;\n background: url('../../fixtures/images/retina/angry-birds.png?sprite');\n background: -webkit-image-set(url('../../fixtures/images/retina/angry-birds.png?sprite') 1x, url('../../fixtures/images/retina/angry-birds@2x.png?sprite') 2x);\n background-size: 120%;\n background-position: 30px 20px;\n}\n\n.source.image-default-resolution {\n width: 128px;\n height: 128px;\n background: -webkit-image-set(\n url('../../fixtures/images/retina/minion@3x.png') 3x,\n url('../../fixtures/images/retina/minion.png') 1x,\n url('../../fixtures/images/retina/minion@2x.png') 2x\n );\n}\n.sprite.image-default-resolution {\n width: 128px;\n height: 128px;\n background: -webkit-image-set(\n url('../../fixtures/images/retina/minion@3x.png?sprite') 3x\n url('../../fixtures/images/retina/minion.png?sprite') 1x,\n url('../../fixtures/images/retina/minion@2x.png?sprite') 2x,\n );\n}\n\n.source.image-set-different {\n width: 128px;\n height: 128px;\n background: url('../../fixtures/images/retina/captain-america.png');\n background: -webkit-image-set(\n url('../../fixtures/images/retina/captain-america.png') 1x,\n url('../../fixtures/images/retina/captain-america@2x.png') 2x,\n url('../../fixtures/images/retina/captain-america@3x.png') 3x\n );\n}\n.sprite.image-set-different {\n width: 128px;\n height: 128px;\n background: url('../../fixtures/images/retina/captain-america.png?sprite');\n background: -webkit-image-set(\n url('../../fixtures/images/retina/captain-america.png?sprite') 1x,\n url('../../fixtures/images/retina/captain-america@2x.png?sprite=other-sprite') 2x,\n url('../../fixtures/images/retina/captain-america@3x.png') 3x\n );\n} */\n",""])},function(e,n){e.exports=function(e){return"string"!=typeof e?e:(/^['"].*['"]$/.test(e)&&(e=e.slice(1,-1)),/["'() \t\n]/.test(e)?'"'+e.replace(/"/g,'\\"').replace(/\n/g,"\\n")+'"':e)}},function(e,n){e.exports=function(e){var n=[];return n.toString=function(){return this.map(function(n){var t=function(e,n){var t=e[1]||"",r=e[3];if(!r)return t;if(n&&"function"==typeof btoa){var i=(o=r,"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */"),a=r.sources.map(function(e){return"/*# sourceURL="+r.sourceRoot+e+" */"});return[t].concat(a).concat([i]).join("\n")}var o;return[t].join("\n")}(n,e);return n[2]?"@media "+n[2]+"{"+t+"}":t}).join("")},n.i=function(e,t){"string"==typeof e&&(e=[[null,e,""]]);for(var r={},i=0;i<this.length;i++){var a=this[i][0];"number"==typeof a&&(r[a]=!0)}for(i=0;i<e.length;i++){var o=e[i];"number"==typeof o[0]&&r[o[0]]||(t&&!o[2]?o[2]=t:t&&(o[2]="("+o[2]+") and ("+t+")"),n.push(o))}},n}},function(e,n,t){var r,i,a={},o=(r=function(){return window&&document&&document.all&&!window.atob},function(){return void 0===i&&(i=r.apply(this,arguments)),i}),s=function(e){var n={};return function(e){return void 0===n[e]&&(n[e]=function(e){return document.querySelector(e)}.call(this,e)),n[e]}}(),u=null,p=0,c=[],f=t(8);function d(e,n){for(var t=0;t<e.length;t++){var r=e[t],i=a[r.id];if(i){i.refs++;for(var o=0;o<i.parts.length;o++)i.parts[o](r.parts[o]);for(;o<r.parts.length;o++)i.parts.push(h(r.parts[o],n))}else{var s=[];for(o=0;o<r.parts.length;o++)s.push(h(r.parts[o],n));a[r.id]={id:r.id,refs:1,parts:s}}}}function l(e,n){for(var t=[],r={},i=0;i<e.length;i++){var a=e[i],o=n.base?a[0]+n.base:a[0],s={css:a[1],media:a[2],sourceMap:a[3]};r[o]?r[o].parts.push(s):t.push(r[o]={id:o,parts:[s]})}return t}function g(e,n){var t=s(e.insertInto);if(!t)throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");var r=c[c.length-1];if("top"===e.insertAt)r?r.nextSibling?t.insertBefore(n,r.nextSibling):t.appendChild(n):t.insertBefore(n,t.firstChild),c.push(n);else{if("bottom"!==e.insertAt)throw new Error("Invalid value for parameter 'insertAt'. Must be 'top' or 'bottom'.");t.appendChild(n)}}function x(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e);var n=c.indexOf(e);n>=0&&c.splice(n,1)}function b(e){var n=document.createElement("style");return e.attrs.type="text/css",m(n,e.attrs),g(e,n),n}function m(e,n){Object.keys(n).forEach(function(t){e.setAttribute(t,n[t])})}function h(e,n){var t,r,i,a;if(n.transform&&e.css){if(!(a=n.transform(e.css)))return function(){};e.css=a}if(n.singleton){var o=p++;t=u||(u=b(n)),r=y.bind(null,t,o,!1),i=y.bind(null,t,o,!0)}else e.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(t=function(e){var n=document.createElement("link");return e.attrs.type="text/css",e.attrs.rel="stylesheet",m(n,e.attrs),g(e,n),n}(n),r=function(e,n,t){var r=t.css,i=t.sourceMap,a=void 0===n.convertToAbsoluteUrls&&i;(n.convertToAbsoluteUrls||a)&&(r=f(r));i&&(r+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(i))))+" */");var o=new Blob([r],{type:"text/css"}),s=e.href;e.href=URL.createObjectURL(o),s&&URL.revokeObjectURL(s)}.bind(null,t,n),i=function(){x(t),t.href&&URL.revokeObjectURL(t.href)}):(t=b(n),r=function(e,n){var t=n.css,r=n.media;r&&e.setAttribute("media",r);if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}.bind(null,t),i=function(){x(t)});return r(e),function(n){if(n){if(n.css===e.css&&n.media===e.media&&n.sourceMap===e.sourceMap)return;r(e=n)}else i()}}e.exports=function(e,n){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(n=n||{}).attrs="object"==typeof n.attrs?n.attrs:{},n.singleton||(n.singleton=o()),n.insertInto||(n.insertInto="head"),n.insertAt||(n.insertAt="bottom");var t=l(e,n);return d(t,n),function(e){for(var r=[],i=0;i<t.length;i++){var o=t[i];(s=a[o.id]).refs--,r.push(s)}e&&d(l(e,n),n);for(i=0;i<r.length;i++){var s;if(0===(s=r[i]).refs){for(var u=0;u<s.parts.length;u++)s.parts[u]();delete a[s.id]}}}};var v,k=(v=[],function(e,n){return v[e]=n,v.filter(Boolean).join("\n")});function y(e,n,t,r){var i=t?"":r.css;if(e.styleSheet)e.styleSheet.cssText=k(n,i);else{var a=document.createTextNode(i),o=e.childNodes;o[n]&&e.removeChild(o[n]),o.length?e.insertBefore(a,o[n]):e.appendChild(a)}}},function(e,n){e.exports=function(e){var n="undefined"!=typeof window&&window.location;if(!n)throw new Error("fixUrls requires window.location");if(!e||"string"!=typeof e)return e;var t=n.protocol+"//"+n.host,r=t+n.pathname.replace(/\/[^\/]*$/,"/");return e.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,function(e,n){var i,a=n.trim().replace(/^"(.*)"$/,function(e,n){return n}).replace(/^'(.*)'$/,function(e,n){return n});return/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/)/i.test(a)?e:(i=0===a.indexOf("//")?a:0===a.indexOf("/")?t+a:r+a.replace(/^\.\//,""),"url("+JSON.stringify(i)+")")})}}]);