Reputation: 239
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
Upvotes: 5
Views: 15338
Reputation: 381
You can build your app with the following command:
ng build --prod --deploy-url='myApp/' --outputPath='dist/myApp.war'
the --deploy-url will handle the references for the produced *.js. if you have problem with your assets, create an index.prod.html with the correct references i.e
<link href="/myApp/assets/css/pe-icon-7-stroke.css" rel="stylesheet" />
Then add the following in the angular.json
"production": {
"fileReplacements": [
{
"replace": "src/index.html",
"with": "src/index.prod.html"
}
To deploy copy myApp.war to jboss_dir/standalone/deployments, and perform touch jboss_dir/standalone/deployments/myApp.war.dodeploy
Upvotes: 0
Reputation: 421
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 );
};
Upvotes: 1
Reputation: 293
We have same requirement, this is how we generate the *.war and manage to deploy into jboss/wildfly application.
Before doing this, required the gulp
installed into your machine. And libraries in required('****')
have be in package.json
devDependencies
, otherwise will hit error.
index.html
change to <base href="/">
gulpfile.js
put the code:`
var gulp = require('gulp')
, war = require('gulp-war')
, zip = require('gulp-zip')
, clean = require('gulp-clean')
, runSequence = require('run-sequence'),
const distWar='./distwar';
const warFileName='lovely';
// This will run in this order:
// * build-clean
// * build-scripts and build-styles in parallel
// * build-html
// * Finally call the callback function
gulp.task('build:war', function (callback) {
runSequence(
'war:clean-dist',
'war:build-war',
callback);
});
gulp.task('war:clean-dist', function () {
return gulp.src(distWar, { read: false })
.pipe(clean());
});
gulp.task('war:build-war', function () {
gulp.src(["dist/**"])
.pipe(war({
welcome: 'index.html',
displayName: warFileName
}))
.pipe(zip(warFileName+'.war'))
.pipe(gulp.dest(distWar));
});
`
gulp build:war
at your gulpfile.js
directory.lovely.war
will appear at directory ./distwar/
lovely.war
into standalone
wildfly directory.http://localhost:8080/lovely/
Upvotes: 0
Reputation: 313
Without having war i am not sure that angular app will be deployed on jboss.
To deploy your AngularJS application on JBoss, I'd suggest you to create a web project and have it builded and packaged as a ready-to-deploy WAR archive using a build manager such as Maven.
As an example, you can follow the kitchensink-angularjs quickstart provided by JBoss.
Upvotes: 0