<#ibiztemplate> TARGET=PSSYSAPP const path = require('path'); const os = require('os'); function resolve(dir) { return path.join(__dirname, dir) } <#assign indexPageCount = 0/> module.exports = { publicPath: './', // 去除 map 文件 productionSourceMap: false, outputDir:"../${pub.getCodeName()?lower_case}-srv/target/classes/META-INF/resources", devServer: { host: '0.0.0.0', port: 8111, compress: true, disableHostCheck: true, proxy: "http://127.0.0.1:8080/${app.getPKGCodeName()}", historyApiFallback: { rewrites: [ <#if app.getAllRefPSAppViews()??> <#list app.getAllRefPSAppViews() as appview> <#if appview.getViewType() == "APPINDEXVIEW" && !appview.isDefaultPage()> { from: /^\/${appview.getCodeName()?lower_case}$/, to: '/${appview.getCodeName()?lower_case}.html' }, ] } }, pages: { <#if app.getAllRefPSAppViews()??> <#list app.getAllRefPSAppViews() as appview> <#if appview.getViewType() == "APPINDEXVIEW" && !appview.isDefaultPage()> <#assign indexPageCount = indexPageCount + 1/> ${appview.getCodeName()?lower_case}: { // page 的入口 entry: 'src/pages/${srffilepath2(appview.getPSAppModule().getCodeName())}/${srffilepath2(appview.getCodeName())}/main.ts', // 模板来源 template: 'src/template.html', // 在 dist/index.html 的输出 filename: '${appview.getCodeName()?lower_case}.html', // 当使用 title 选项时, // template 中的 title 标签需要是 <%= htmlWebpackPlugin.options.title %> title: '${appview.getTitle()}', // 在这个页面中包含的块,默认情况下会包含 // 提取出来的通用 chunk 和 vendor chunk。 // chunks: ['chunk-vendors', 'chunk-common', 'index'] }, <#if app.getDefaultPSAppView()??> <#assign defView = app.getDefaultPSAppView()/> <#assign indexPageCount = indexPageCount + 1/> ${defView.getCodeName()?lower_case}: { // page 的入口 entry: 'src/pages/${srffilepath2(defView.getPSAppModule().getCodeName())}/${srffilepath2(defView.getCodeName())}/main.ts', // 模板来源 template: 'src/template.html', // 在 dist/index.html 的输出 filename: 'index.html', // 当使用 title 选项时, // template 中的 title 标签需要是 <%= htmlWebpackPlugin.options.title %> title: '${defView.getTitle()}', // 在这个页面中包含的块,默认情况下会包含 // 提取出来的通用 chunk 和 vendor chunk。 // chunks: ['chunk-vendors', 'chunk-common', 'index'] }, }, // 多核打包 parallel: os.cpus().length > 1, chainWebpack: (config) => { <#if app.getDefaultPSAppView()??> <#assign defView = app.getDefaultPSAppView()/> // 删除自动计算预加载资源 config.plugins.delete('preload-${defView.getCodeName()?lower_case}') // 删除预加载资源 config.plugins.delete('prefetch-${defView.getCodeName()?lower_case}') <#if app.getAllRefPSAppViews()??> <#list app.getAllRefPSAppViews() as appview> <#if appview.getViewType() == "APPINDEXVIEW" && !appview.isDefaultPage()> config.plugins.delete('preload-${appview.getCodeName()?lower_case}') config.plugins.delete('prefetch-${appview.getCodeName()?lower_case}') config.resolve.alias .set('@ibizsys', resolve('src/ibizsys')) .set('@pages', resolve('src/pages')) .set('@components', resolve('src/components')) .set('@widget', resolve('src/widget')) .set('@engine', resolve('src/engine')) .set('@interface', resolve('src/interface')) .set('@locale', resolve('src/locale')) }, configureWebpack: config => { if (Object.is(config.mode, 'production')) { // 多核启动编译及内存提升 const data = config.plugins[9 + ${indexPageCount}]; // 最大进程数 data.workersNumber = os.cpus().length > 4 ? 4 : os.cpus().length; // 会占用额外内存不释放,不建议开发阶段使用 // 单个进程最大使用内存 data.memoryLimit = 4096; } else { // 多核启动编译及内存提升 const data = config.plugins[7 + ${indexPageCount}]; // 最大进程数 // data.workersNumber = os.cpus().length > 4 ? 4 : os.cpus().length; // 会占用额外内存不释放,不建议开发阶段使用 // 单个进程最大使用内存 data.memoryLimit = 4096; } }, }