app-lib-cli-plugin-server
Version:
app-lib-cli-plugin-server
2 lines • 5.74 kB
JavaScript
!function(e,n){if("object"==typeof exports&&"object"==typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else{var r=n();for(var t in r)("object"==typeof exports?exports:e)[t]=r[t]}}(this,(()=>{return e={138:(e,n,r)=>{const t=r(495),o=r(177);e.exports={start:e=>{let{log:n,utils:{praseOpt:r,prase:s,bindArg:i},OPTIONS:a,ARGUMENTS:p,CONSTANT:{TARGET:l},STATIC:{jsonToFile:c}}=e;c(o);const u={es:t};return(()=>{let e=[];for(let n in u)e.push(n)})(),{init:(e,n)=>{const r=n.commander.Option,t=i(s,n.commander.InvalidArgumentError);return e.argument(...p.language(n)).addOption(new r("-p, --port <number>","server port").argParser(t.port).default(8080,"8080")).addOption(new r("-h, --host [string]","support ip address for visit")).addOption(new r("-m, --model [string]","support [example,test] ")).addOption(a.message(n.commander)).description("start language service")},start:async t=>{const o=r(t);let{arg:s}=o;n.md("execute params:",o);let i=u[s[0]];if(!i)throw n.me(`no exsit function ${s[0]} to deal this commond,please develop this deal function`);return await i(o,t,e)}}}}},495:e=>{e.exports=async(e,n,r)=>{let{log:t,exec:o,nodeUtils:{getBin:s,getCanUsePort:i,isSysUsePort:a,readline:p},utils:{optionsToArray:l,getStaticPath:c}}=r,{option:u}=e,d=1*u.port,g=c(`${n.commond}.${n.options[0]}.webpack.${u.model?u.model+".":""}config.js`),f=s("webpack-dev-server");if(await a(d)){let e=await i(d+1);t.mwn(`[${d}] port is EADDRINUSE, use [${e}]?`);let n=await p("yes/no","yes");if("y"!==n&&"yes"!=n)return t.mwn("npm init",`give up use port [${e}]`);d=e}return u.port=d,o(f,["--config",g].concat(l(u,["target","model"])),{stdio:"inherit"}),0}},177:e=>{"use strict";e.exports=JSON.parse("[{\"name\":\"server.es.webpack.config.js\",\"content\":\"// 开发模式\\r\\nconst { log } = require('app-lib-log');\\r\\nconst { resolve, getTemplate } = require('app-lib-node')\\r\\nconst realPath = (p) => resolve(__dirname, process.cwd() + '/' + p);\\r\\nconst HTMLWebpackPlugin = require('html-webpack-plugin');\\r\\nconst {autoRequire} = require(\\\"app-lib-nobuild\\\");\\r\\n\\r\\n\\r\\nconst config = {\\r\\n devtool: 'inline-source-map',\\r\\n entry: {\\r\\n index: resolve('./src/index.js'),\\r\\n },\\r\\n output: {\\r\\n path: resolve(\\\"./\\\"),\\r\\n filename: '[name].js',\\r\\n },\\r\\n module: {\\r\\n },\\r\\n plugins: [\\r\\n new HTMLWebpackPlugin({\\r\\n template: getTemplate() // 使用模版\\r\\n })\\r\\n ],\\r\\n resolve: {\\r\\n extensions: ['.js', '.jsx', '.json'], // 不用编写的后缀\\r\\n alias: {\\r\\n // // 配置快捷使用\\r\\n // \\\"appbir_utils\\\": resolve('./src/subproject/src/main.js'),\\r\\n // \\\"@\\\": resolve('../'),\\r\\n }\\r\\n },\\r\\n devServer: {\\r\\n // contentBase: path.join(__dirname, \\\"\\\"), //运行的根目录(转换后的目录)\\r\\n open: true, // 在运行成功后,自动打开浏览器,并保持实时更新\\r\\n port: 9000, // 自定义的端口号\\r\\n hot: true,\\r\\n // proxy: { // 服务运行的代理\\r\\n // '/api': { \\r\\n // target: 'https://localhost:8888', // 代理默认地址到数据库\\r\\n // pathRewrite: {\\r\\n // '^/api': ''\\r\\n // },\\r\\n // // 默认代理服务器,会以我们实际在浏览器请求的主机名【localhost:8080】,作为代理服务器的主机名,\\r\\n // // 然后代理服务器会带上这个主机名,去请求github,然而 github是不认识 【localhost:8080】\\r\\n // // changeOrigin: true 就是以实际代理请求发生过程中的主机名去请求,如:代理服务器的主机名\\r\\n // changeOrigin: true\\r\\n // }\\r\\n // }\\r\\n }\\r\\n};\\r\\n\\r\\n\\r\\n\\r\\n/*************************************************************************************\\r\\n * \\r\\n * 支持定义配置\\r\\n * \\r\\n *************************************************************************************/\\r\\nconst { APPEND } = process.env;\\r\\n\\r\\nlet customConfig = null;\\r\\n\\r\\nif (APPEND) {\\r\\n customConfig = autoRequire(realPath(APPEND));\\r\\n} else {\\r\\n let defaultConfig = null;\\r\\n let diyPath = realPath('./config/server.es.append.config.js');\\r\\n try {\\r\\n defaultConfig = autoRequire(diyPath);\\r\\n } catch (e) {\\r\\n log.mi(`use default webpack config! diy in [${diyPath}]`)\\r\\n }\\r\\n if (defaultConfig) {\\r\\n customConfig = defaultConfig(config);\\r\\n log.md('you define config:', customConfig)\\r\\n }\\r\\n}\\r\\n\\r\\nmodule.exports = customConfig ? customConfig : config;\"},{\"name\":\"server.es.webpack.example.config.js\",\"content\":\"// 案列\\r\\nconst { resolve } = require('app-lib-node')\\r\\nconst config = require('./server.es.webpack.config.js');\\r\\nconsole.log(\\\"config\\\",config);\\r\\nconfig.entry= {\\r\\n index: resolve('./example/es/index.js'),\\r\\n},\\r\\nmodule.exports = config;\"},{\"name\":\"server.es.webpack.test.config.js\",\"content\":\"const { resolve, getTemplate } = require('app-lib-node')\\r\\n// 测试\\r\\nconst config = require('./server.es.webpack.config.js');\\r\\nconfig.entry= {\\r\\n index: resolve('./example/node/index.js'),\\r\\n},\\r\\nmodule.exports = config;\"}]")}},n={},function r(t){var o=n[t];if(void 0!==o)return o.exports;var s=n[t]={exports:{}};return e[t](s,s.exports,r),s.exports}(138);var e,n}));
//# sourceMappingURL=index-min.js.map