1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
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' },
</#if>
</#list>
</#if>
]
}
},
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 标签需要是 <title><%= htmlWebpackPlugin.options.title %></title>
title: '${appview.getTitle()}',
// 在这个页面中包含的块,默认情况下会包含
// 提取出来的通用 chunk 和 vendor chunk。
// chunks: ['chunk-vendors', 'chunk-common', 'index']
},
</#if>
</#list>
</#if>
<#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 标签需要是 <title><%= htmlWebpackPlugin.options.title %></title>
title: '${defView.getTitle()}',
// 在这个页面中包含的块,默认情况下会包含
// 提取出来的通用 chunk 和 vendor chunk。
// chunks: ['chunk-vendors', 'chunk-common', 'index']
},
</#if>
},
// 多核打包
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>
<#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}')
</#if>
</#list>
</#if>
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;
}
},
}