text: "use strict";function _interopRequireWildcard(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t.default=e,t}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function ResourcePlugin(e){this.options=e}var _path=require("path"),_path2=_interopRequireDefault(_path),_aaptjs=require("aaptjs"),_aaptjs2=_interopRequireDefault(_aaptjs),_info=require("../../common/info"),info=_interopRequireWildcard(_info),_shared=require("../../common/shared"),_utils=require("../../common/utils"),FILE_EXT_LIST=info.name.extList,FILE_EXT_NORES=FILE_EXT_LIST.concat([".js",".jsx",".coffee",".ts",".tsx",".vue",".css",".less",".sass",".styl",".html",".json",".md"]);ResourcePlugin.prototype.apply=function(e){var t=this.options,i=e.options;e.plugin("watch-run",function(e,t){Object.keys(i.entry).forEach(function(e){var t=i.entry[e];t instanceof Array&&!/app\.js/.test(e)&&-1!==t[0].indexOf("webpack-dev-server")&&t.shift()}),t()}),e.plugin("emit",function(e,i){function o(){--l>0||(_utils.colorconsole.log("### App Loader ### build目录构建完成"),i())}var n=t.pathSrc,s=t.pathBuild,r=this.inputFileSystem,a=this.outputFileSystem,u=(0,_utils.collectResFile)(r,n,s,FILE_EXT_NORES),l=Object.keys(u).length;Object.keys(u).forEach(function(e){var t=u[e];a.mkdirp(_path2.default.dirname(e),function(){var i=r.statSync(t);if(i&&i.isFile()){/.+\.9\.png$/.test(_path2.default.basename(t))?_aaptjs2.default.singleCrunch(t,e,function(e){e&&_utils.colorconsole.log("### App Loader ### 转换资源文件("+t+")失败："+e.message),o()}):r.readFile(t,function(i,n){i&&_utils.colorconsole.log("### App Loader ### 复制资源文件("+t+")失败："+i.message),a.writeFile(e,n,function(e){e&&_utils.colorconsole.log("### App Loader ### 复制资源文件("+t+")失败："+e.message),o()})})}})})}),e.plugin("emit",function(e,i){var o=t.pathSrc,n=t.pathBuild,s=this.inputFileSystem,r=this.outputFileSystem,a=_path2.default.join(o,"manifest.json"),u=_path2.default.join(n,"manifest.json");if(-1!==s.readdirSync(o).indexOf("manifest.json")){var l=s.readFileSync(a,"utf8"),c=(0,_shared.updateManifestCont)(l,t).manifestCont;r.writeFile(u,c,"utf8",function(e){e&&_utils.colorconsole.error("### App Loader ### 更新资源文件("+u+")失败："+e.message),i()})}else _utils.colorconsole.error("### App Loader ### "+o+"目录下无资源文件manifest.json"),i()})},module.exports=ResourcePlugin;