我的Angular 18应用程序在开发模式下使用SSR运行平稳。但是,当我切换到优化设置为true的生产模式时,应用程序无法定位
'igv.js'
文件,即使它已经包含在
angular.json
文件。
配置部分:
"configurations": {
"production": {
"budgets": [
{
"type": "anyComponentStyle",
"maximumWarning": "6kb"
}
],
"optimization": true,
"sourceMap": true,
"namedChunks": true,
"extractLicenses": true,
"outputHashing": "all"
},
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true
}
},
脚本部分:
"scripts": [
"node_modules/swagger-ui-dist/swagger-ui-bundle.js",
"node_modules/swagger-ui-dist/swagger-ui-standalone-preset.js",
"igv.js"
],
这就是我对IGV模块的调用方式。由于我使用的是SSR,我必须在客户端调用该文件。
ngAfterViewInit() {
if (this.isBrowser) {
import('igv').then(igvModule => {
const igv = igvModule.default;
if (igv && typeof igv.createBrowser === 'function') {
this.igvModule = igv;
} else {
console.error('igv.createBrowser is not a function');
}
}).catch(error => {
console.error('Error loading igv module:', error);
});
}
}
关于可能遗漏的内容,有什么建议吗?