UNPKG

@mobileaction/ui-modules

Version:

Mobile Action common modules for Vue projects

2 lines (1 loc) 1.03 kB
"use strict";var o=require("webpack"),t=require("schema-utils");function e(o){return o&&"object"==typeof o&&"default"in o?o:{default:o}}var n=e(o),a=e(t);const p=n.default,{validate:s}=a.default,i={type:"object",properties:{path:{type:"string"},appInfo:{type:"object"}}};var r=class{constructor(o={}){const t=Object.assign({path:"app-info.json",appInfo:null},o);s(i,t,{name:"MaAppInfoPlugin",baseDataPath:"options"}),this.options=t}apply(o){const{appInfo:t,path:e}=this.options;if(!t)return void console.warn("MaAppInfo: empty app info provided file will not be generated");if(!e)return void console.warn("MaAppInfo: Invalid app info path provided file will not be generated");const n=JSON.stringify(t);if("4"===p.version[0])return void o.hooks.emit.tapAsync(`MaAppInfoPlugin: ${e} body=${n}`,((o,t)=>{o.assets[e]={source:()=>n,size:()=>n.length},t()}));const{sources:a}=p;o.hooks.compilation.tap("MaAppInfo",(o=>{o.hooks.additionalAssets.tapAsync("MaAppInfo",(t=>{o.assets[e]=new a.RawSource(n),t()}))}))}};module.exports=r;