node package manager


Web build tools

npm Build status GitHub repository

Gulp tasks generator for projects following my conventional structure.

This is intend for multi-target Typescript libraries or applications. It adds compilation, lint rules, unit-tests and resource management. It supports both Node and browser builds.

Here is a list of some of the main tools bundled with this package: Typescript, mocha, TSLint, pug, sass, webpack.

Standard project layout

├── build/          # Development builds
├── dist/           # Distributed files (this goes to npm)
├── docs/           # Advanced documentation for the library
├── src/            # Scripts, assets and tests
├──    # Describe all the changes
├── # How to build and work on the project
├──      # Generally MIT
├──       # To match requirements of third-party tools
├──       # Projects presentation
├── package.json    # Project's metadata
└── gulpfile.js     # Definition of Gulp tasks


This library generate gulp tasks for targets in the context of a project. A target is basically a final build, and a project is a set of targets.

There are currently 3 supported targets:

  • Node: Generate a Node package, either an executable or a library. It only compiles Typescript files.
  • Angular: Generate an Angular application, for the server. It compiles Typescript files, builds Pug and Sass files and copy assets.
  • Test: Build and run the unit-tests with Node. It is mainly to test a node target.

The project configuration defines were are the package.json, src directory, build directory, etc.

A target configuration defines the files to compile and the specific options.

To generate general tasks (:lint, :bump-minor, etc.), use:

import * as buildTools from "demurgos-web-build-tools";
import gulp = require("gulp");
// Project-wide options
const projectOptions = Object.assign(
    root: __dirname
buildTools.projectTasks.registerAll(gulp, projectOptions);

To generate a target, use:

import * as buildTools from "demurgos-web-build-tools";
import gulp = require("gulp");
// Project-wide options
const projectOptions = buildTools.config.DEFAULT_PROJECT_OPTIONS;
// Preconfigured targets
// Node library
const libTarget = buildTools.config.LIB_TARGET;
// Mocha tests
const libTestTarget = buildTools.config.LIB_TEST_TARGET;
// Webpack build for angular config
const angularClientTarget = buildTools.config.ANGULAR_CLIENT_TARGET;
// buildTools.targetGenerators.<kind>.generateTarget(gulp, project, target);
buildTools.targetGenerators.node.generateTarget(gulp, projectOptions, libTarget);
buildTools.targetGenerators.test.generateTarget(gulp, projectOptions, libTestTarget);
buildTools.targetGenerators.webpack.generateTarget(gulp, projectOptions, angularClientTarget);


Project Options


  • Type: string

Path to the root of your project. This is the only path allowed to be absolute.


  • Type: string

Relative path from project.root to your package.json file.


  • Type: string

Relative path from project.root to your package.json file.


  • Type: string

Relative path from project.root to the directory containing the sources of your project.


  • Type: string

Relative path from project.root to the directory where the output of the builds should be placed.

This directory is usually ignored by your version control system.


  • Type: string

Relative path from project.root to the directory containing the builds you wish to publish or export (distribute).


  • Type:
    interface TslintOptions {
       * Path to the output tslint.json file, relative to `root`
      tslintJson?: string;
       * Extend the default configuration (merge them).
       * This can either be path relative to `root` or a raw config object (content of tslint.json).
       * If you pass a raw config object, its configFileDir will be `root`.
      configuration?: TslintConfiguration.RawConfigFile | string,
      formatter?: "msbuild" | "verbose" | string;
       * The files to lint, relative to `root`
      files?: string[];
       * Instance of tslint to use
      tslint?: any;

This allows you to configure the lint rules.

Project Tasks


  1. Increments the major version of the project
  2. Creates a git commit Release <version>. (example: Release 2.2.1)
  3. Creates a git tag v<version> with the message Release <version>. (Example: name: v2.2.1, message: Release 2.2.1)


Same as :bump-major but increments the minor version.


Same as :bump-major but increments the patch version.


Check the Typescript files with TSLint. See src/lib/config/tslint.ts for the default configuration.

node target

Options for a node target


  • Type: string

Name of the target. This is used as the prefix for each task. For example, "name": "foo" leads to gulp foo:build.


  • Type: string
  • Default:

Relative path from project.buildDir to the directory containing the output of this target. This is usually a subdirectory of project.buildDir.


  • Type: string[]

Relative patterns from project.srcDir to match the *.ts files to compile for this target.


  • Type: string[]

Relative paths from project.srcDir to the directories containing ths *.d.ts type definition files of third-party libraries.


  • Type: TypescriptOptions
  • Optional

Advanced Typescript options. See src/lib/config/config.ts.


  • Type: CopyOptions[]
  • Optional

Copy some files during the build process.


  • Type: PugOptions[]
  • Optional

Render some HTML files from Pug templates during the build process.


  • Type: SassOptions[]
  • Optional

Render some CSS files from *.scss files during the build process.


  • Type: string

Relative module id (path without the extension) from target.srcDir of the main module.

This is usually the file to start when running the project or the entry point of the library.

Tasks for a node target


Build the complete target and output its result to target.targetDir.


Compile the Typescript files.


Perform simple copies.


Compile Pug templates.


Compile *.scss files.


Delete the files of this target in project.buildDir and project.distDir.


Clean the files, build the target and then copy it to distDir (ready for publication).


Generate as tsconfig.json file in the base directory for this target so you can compile it without gulp and just tsc:

Example for the target api-server with the baseDirectory server:

gulp api-server:tsconfig.json
cd src/server
# The target `api-server` is now built


Recompile when the files change.

Target webpack

Options: see src/lib/config/config.ts


Target test

Options: see src/lib/config/config.ts