uni-plugin-light
Version:
uni-app相关插件、loader及webpack基础配置
2 lines (1 loc) • 1.66 kB
JavaScript
;var e=require("t-comm"),r=require("loader-utils");function t(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}require("fs");var n=t(require("path"));function o(e){return n.relative(process.cwd(),n.resolve(e))}var l="LOADER_LOGS";function i(e,r){global[l]||(global[l]={}),global[l][e]||(global[l][e]=[]),global[l][e].push(r)}var a="ALL";function c(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=(r.getOptions(this)||{}).platforms,n=void 0===t?e:t,o=process.env.UNI_PLATFORM||"";return n===a||n.indexOf(a)>-1||n.includes(o)}var u=["mp-weixin","mp-qq"];module.exports=function(t){if(e.replaceAllPolyfill(),!c.call(this,u))return t;var n=r.getOptions(this)||{},l=n.replaceLibraryList,a=void 0===l?[]:l,f=n.replaceContentList,s=void 0===f?[]:f;if(!(null!=a&&a.length||s.length))return t;for(var p=this.resourcePath,v=0;v<s.length;v++){var g=s[v],h=g.path,b=g.content,d=void 0===b?"":b,O="function"==typeof d?d():d;if(p.match(new RegExp(h)))return i("replace-library.json",{file:o(p),type:"CONTENT",path:h}),O}for(var m=t,y=function(){var e=a[L],r=e.from,t=e.to;if(e.exact)m=m.replaceAll("'".concat(r,"'"),"'".concat(t,"'"));else{var n=new RegExp("(?<=import(?:[\\s\\S]+from)?\\s+)(?:'|\")(".concat(r,"[\\w\\/\\-\\.]*)(?:'|\")"));n.test(m)&&(m=m.replaceAll(n,(function(){return"'".concat(t,"'")})),i("replace-library.json",{file:o(p),type:"LIBRARY",from:r,to:t}))}},L=0;L<a.length;L++)y();return m};