gant-core 0.2.4 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var e=require("../../utils/index.js"),t=require("html-webpack-plugin"),s=require("./cssRules.js"),r=require("path"),i=require("webpack"),a=require("../../config/index.js");const o=["name","routes","mpas","packages","microServiceMap","base","customHistoryApiFallback","outputPathDir","define","setting","vue","library","compression","terserOptions","htmlTemplatePath","locales","mfa","publicPathDir"];exports.getDefaultConfig=(n,l)=>{const u=a.omit(l,o);let{base:c="/",routes:p,htmlTemplatePath:m,outputPathDir:d="dist",microServiceMap:g,define:h,setting:f,vue:v}=a.pick(l,o);c=/^\/.*\/$/.test(c)?c:"/";let y=l.entry||{};const b=[];if(a.isEmpty(y)&&(y.index=r.resolve(n,"src/main")),"string"==typeof y.index){const s=e.getMpasPageHtml(m);b.push(new t({templateContent:s,filename:"index.html",chunks:["index"],publicPath:c,base:c})),l.entry=y}a.isEmpty(y)||Object.entries(y).forEach((([s,r])=>{if("index"!==s){const r=e.getMpasPageHtml(m?.replace("index.",s+"."));b.push(new t({templateContent:r,filename:`${s}.html`,chunks:[s],publicPath:c,base:c}))}}));const x=s.getCssRules(l.mode);return e.mergeConfig({entry:y,stats:"minimal",devServer:{static:{directory:r.resolve(n,"src/.gant/public"),publicPath:c},compress:!0,historyApiFallback:a.has(l,"customHistoryApiFallback")?l?.customHistoryApiFallback:{index:r.resolve(c,"index.html"),rewrites:[{from:/^\/public\/(.*)$/,to:e=>r.resolve(c,e.match[1])}]}},module:{rules:[...v?[{test:/\.vue$/,loader:require.resolve("vue-loader")}]:[],{test:/\.(ts|tsx)$/,exclude:/node_modules/,use:{loader:require.resolve("swc-loader"),options:{jsc:{parser:{syntax:"typescript",tsx:!0,dynamicImport:!0},transform:{...v?{}:{react:{runtime:"automatic",development:"development"===l.mode,refresh:"development"===l.mode}}}}}}},...x,{test:/\.html$/,use:require.resolve("html-loader")},{test:/\.(png|jpg|gif|woff|woff2|eot|ttf|svg)$/i,use:[{loader:require.resolve("url-loader"),options:{limit:8192,name:"[name][hash].[ext]",outputPath:"assets/"}}]}]},resolve:{extensions:[".tsx",".ts",".js",".jsx",".json",".vue"]},output:{path:r.resolve(n,d),publicPath:c,charset:!0,clean:!0},plugins:[...v?[new(require("vue-loader").VueLoaderPlugin)]:[],...b,new i.ProvidePlugin({React:"react"}),new i.ProgressPlugin,new i.DefinePlugin({GANT_START_TIME:JSON.stringify(global.__gant_start_time),microServiceMap:JSON.stringify(g),BASE:JSON.stringify(c),SETTING:JSON.stringify(f||{}),...a.mapValues(h,(e=>JSON.stringify(e))),"process.env":JSON.stringify(process.env)})]},u)};
2
+ "use strict";var e=require("../../utils/index.js"),t=require("html-webpack-plugin"),s=require("./cssRules.js"),r=require("path"),i=require("webpack"),o=require("../../config/index.js");const a=["name","routes","mpas","packages","microServiceMap","base","customHistoryApiFallback","outputPathDir","define","setting","vue","library","compression","terserOptions","htmlTemplatePath","locales","mfa","publicPathDir","provide"];exports.getDefaultConfig=(n,l)=>{const u=o.omit(l,a);let{base:p="/",routes:c,htmlTemplatePath:m,outputPathDir:d="dist",microServiceMap:g,define:h,setting:v,vue:f,provide:y}=o.pick(l,a);p=/^\/.*\/$/.test(p)?p:"/";let b=l.entry||{};const x=[];if(o.isEmpty(b)&&(b.index=r.resolve(n,"src/main")),"string"==typeof b.index){const s=e.getMpasPageHtml(m);x.push(new t({templateContent:s,filename:"index.html",chunks:["index"],publicPath:p,base:p})),l.entry=b}o.isEmpty(b)||Object.entries(b).forEach((([s,r])=>{if("index"!==s){const r=e.getMpasPageHtml(m?.replace("index.",s+"."));x.push(new t({templateContent:r,filename:`${s}.html`,chunks:[s],publicPath:p,base:p}))}}));const P=s.getCssRules(l.mode);return e.mergeConfig({entry:b,stats:"minimal",devServer:{static:{directory:r.resolve(n,"src/.gant/public"),publicPath:p},compress:!0,historyApiFallback:o.has(l,"customHistoryApiFallback")?l?.customHistoryApiFallback:{index:r.resolve(p,"index.html"),rewrites:[{from:/^\/public\/(.*)$/,to:e=>r.resolve(p,e.match[1])}]}},module:{rules:[...f?[{test:/\.vue$/,loader:require.resolve("vue-loader")}]:[],{test:/\.(ts|tsx)$/,exclude:/node_modules/,use:{loader:require.resolve("swc-loader"),options:{jsc:{parser:{syntax:"typescript",tsx:!0,dynamicImport:!0},transform:{...f?{}:{react:{runtime:"automatic",development:"development"===l.mode,refresh:"development"===l.mode}}}}}}},...P,{test:/\.html$/,use:require.resolve("html-loader")},{test:/\.(png|jpg|gif|woff|woff2|eot|ttf|svg)$/i,use:[{loader:require.resolve("url-loader"),options:{limit:8192,name:"[name][hash].[ext]",outputPath:"assets/"}}]}]},resolve:{extensions:[".tsx",".ts",".js",".jsx",".json",".vue"]},output:{path:r.resolve(n,d),publicPath:p,charset:!0,clean:!0},plugins:[...f?[new(require("vue-loader").VueLoaderPlugin)]:[],...x,new i.ProvidePlugin({...y}),new i.ProgressPlugin,new i.DefinePlugin({GANT_START_TIME:JSON.stringify(global.__gant_start_time),microServiceMap:JSON.stringify(g),BASE:JSON.stringify(p),SETTING:JSON.stringify(v||{}),...o.mapValues(h,(e=>JSON.stringify(e))),"process.env":JSON.stringify(process.env)})]},u)};