plugin-light
Version:
Webpack 相关插件、Loader、基础配置及 CLI 命令
2 lines (1 loc) • 1.61 kB
JavaScript
;Object.defineProperty(exports,"__esModule",{value:!0});var t=require("fs"),e=require("t-comm"),n=require("loader-utils");function r(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}})),e.default=t,Object.freeze(e)}var c=r(t),s="base.scss";function o(t){return c.readdirSync(t).filter((function(t){return t.endsWith("scss")&&!t.startsWith(s)})).map((function(t){return t.replace(/\.scss$/,"")}))}var i="h5",u={MP_WX:".wxss",MP_QQ:".qss",MP_ALIPAY:".acss",MP_JD:".jxss"};Object.keys(u).reduce((function(t,e){return t[e]=u[e].slice(1),t}),{});var a="ALL";function l(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=(n.getOptions(this)||{}).platforms,r=void 0===e?t:e,c=process.env.UNI_PLATFORM||"";return r===a||r.indexOf(a)>-1||r.includes(c)}exports.default=function(t){if(!l.call(this,[i]))return t;var r=(n.getOptions(this)||{}).topElement,c=void 0===r?"body":r,s=this.context,u=function(t){var n=e.normalizePath(t).match(/\/([^/]+)\/css/);return(null==n?void 0:n[1])||""}(s);if(!u)return t;var a=function(t){var e=t.styleList,n=t.componentName,r=t.topElement,c=t.dir,s=void 0===c?"":c,o=e.map((function(t){return"\n &--type-".concat(t," {\n @import './").concat(s).concat(t,".scss';\n }")})).join("\n");return"\n".concat(r,".").concat(n," {\n ").concat(o,"\n}\n")}({styleList:o(s),componentName:u,topElement:c,dir:""});return"".concat(t,"\n").concat(a)},exports.getStyleList=o;