Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 5 standalone deployment on jboss 7.1.1

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.

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?

Screenshot of dist folder contents

like image 831
user12 Avatar asked Nov 07 '22 12:11

user12


1 Answers

  1. Install grunt and grunt-war using npm command
  2. Add the below Gruntfile.js in your angular project which means inside your project folder
  3. run "ng build" command and it would produce the dist folder
  4. Go to the project folder and run the "grunt war" command and it will give you the war file as the result which can be deployed into your jboss server
  5. You can change the war file name/war output path and I gave "Test" as the war file name and "warFile" is the output folder.

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 );
};
like image 177
Panneerselvam Avatar answered Nov 11 '22 11:11

Panneerselvam