Deployment as WAR - mgechev/angular-seed GitHub Wiki

  1. Define a destination directory in /tools/config/project.config.ts
WAR_DEST = `${this.DIST_DIR}/`;
  1. Install gulp-war and gulp-zip

npm install --save-dev gulp-war
npm install --save-dev gulp-zip

  1. Create a task tools/tasks/project/build.war.ts:
import * as gulp from 'gulp';

var war = require('gulp-war');
var zip = require('gulp-zip');

import {
    APP_DEST, WAR_DEST
} from '../../config';

export = () => {

    return gulp.src(APP_DEST + '/**')
        .pipe(war({
            welcome: 'index.html',
            displayName: 'THE NAME OF MY APPLICATION',
        }))
        .pipe(zip('theNameOfMyApplication.war'))
        .pipe(gulp.dest(WAR_DEST));
};
  1. Define in project.tasks.json your new gulp task script 'build.war' named e.g. 'build.prod.war' and base it off of build.prod.
    {
    "build.prod.war": [
    "initialize",
    "check.tools",
    "clean.prod",
    "tslint",
    "build.assets.prod",
    "build.html_css",
    "copy.prod",
    "build.js.prod",
    "build.bundles",
    "build.bundles.app",
    "minify.bundles",
    "build.index.prod",
    "sw.manifest.static",
    "minify.index",
    "build.war"
    ]
    }

  2. In package.json, add the new npm script command in scripts:

"build.prod.war": "gulp build.prod.war --color --env-config prod --build-type prod",

Original Source.