function getEntry(entryKeys) {
const idProd = process.env.NODE_ENV === 'production';
const entries = {};
entryKeys.forEach((key) => {
entries[key] = {
entry: `src${key === 'index' ? '' : `/${key}`}/main.ts`,
template: `public/${key}.html`,
filename: `${key}.html`,
[idProd ? 'chunks' : null]: [
'runtime',
...splitChunks配置的js,
key
]
};
});
return entries;
}
const entries = getEntry(['index', 'otherpage']);
module.exports = {
publicPath: '/',
assetsDir: 'public',
pages: entries,
...
}
ng:
location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ /index.html;
charset utf-8; #显示中文
}
location /otherpage{
root /usr/share/nginx/html;
index otherpage.html;
try_files $uri $uri/ /otherpage.html;
charset utf-8; #显示中文
}
location @router {
rewrite ^.*$ /index.html last;
}