问题描述
我构建了一个angular 5应用程序,该应用程序消耗了在其他服务器和主机上远程可用的rest api.在我本地,我正在使用apache服务器来部署可以按预期工作的有角度的应用程序.
I have built an angular 5 app which is consuming rest api available remotely on different server and host. In my local I am using apache server to deploy the angular app which is working as expected.
为了将代码提升到其他环境,我使用"ng build --prod"(角度cli)构建了生产版本,并且在dist文件夹中看到了最终内容.我认为从角度标准来看,它将兼容并更好地建议使用apache服务器,Ngnix等部署角度4/5应用程序.但是根据我的组织限制,我们必须使用jboss来托管Web应用程序.我没有战争档案.我所拥有的只是dist文件夹的内容.您能帮我将角度应用程序部署到jboss吗?
To promote code to other envs, I have built the production build using "ng build --prod" (angular cli) and I see the final contents in dist folder. I think from angular standards, it will be compatible and better suggested to deploy angular 4/5 apps using apache server,Ngnix etc . But according to my organization restrictions, we have to use jboss for the web-app to host. I don't have war file. All I have is contents of dist folder. can you please help me to deploy angular app to jboss?
推荐答案
- 使用npm命令安装grunt和grunt-war
- 将以下Gruntfile.js添加到您的有角度的项目中,这意味着在项目文件夹中
- 运行"ng build"命令,它将产生dist文件夹
- 转到项目文件夹并运行"grunt war"命令,它将为您提供war文件,可以将其部署到jboss服务器中
- 您可以更改war文件名/war输出路径,我给"Test"作为war文件名,"warFile"是输出文件夹.
Gruntfile.js:
Gruntfile.js :
module.exports = function ( grunt ) {
grunt.loadNpmTasks( 'grunt-war' );
var taskConfig = {
war: {
target: {
options: {
war_verbose: true,
war_dist_folder: 'warFile', // Folder path seperator added at runtime.
war_name: 'Test', // .war will be appended if omitted
webxml_welcome: 'index.html',
webxml_display_name: 'Test'
},
files: [
{
expand: true,
cwd: 'dist',
src: ['**'],
dest: ''
}
]
}
}
};
grunt.initConfig( taskConfig );
};
这篇关于jboss 7.1.1上的Angular 5独立部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!