@messageflow/build

1.0.0 • Public • Published

@messageflow/build

Quick build with Gulp


NPM

Version Downloads MIT License Code of Conduct

Build Status CircleCI Dependency Status NSP Status Codecov Coverage Status

codebeat-badge codacy-badge

Better build process with Gulp for general Node.js projects written in TypeScript.

Table of contents

Pre-requisites

Setup

Install

# Install via NPM as one of the `devDependencies`
$ npm install --save-dev @messageflow/build

Usage

gulpfile.js

const gulp = require('gulp');
const { builder } = require('@messageflow/build');

const build = builder();
/** `cleanGlobs` can be helpful when the destination directory is not the `dist` directory. */
// const build = builder({
//   dist: '.',
//   cleanGlobs: [
//     './*.js',
//     './*.d.ts',
//     '!./gulpfile.js',
//     '!./json.d.ts',
//   ],
// });

gulp.task('clean', build.clean);
gulp.task('lint', build.lint);
gulp.task('copy', build.copy);
gulp.task('ts', build.ts);
gulp.task('watch', build.watch);
gulp.task('default', build.default);

API Reference

DEFAULT_IGNORE_GLOBS

[
  '!**/demo*/**/*.ts*',
  '!**/test*/**/*.ts*',
]

DEFAULT_BABEL_CONFIG

{
  presets: [
    ['@babel/preset-env', {
      targets: { node: 'current' },
      spec: true,
      modules: false,
      useBuiltIns: 'usage',
      shippedProposals: true,
    }],
    ['minify', {
      replace: false,
      mangle: { keepFnName: true },
      removeConsole: false,
      removeDebugger: true,
    }],
  ],
}

BuilderParams

  • src <?string> Optional source directory. Defaults to src.
  • dist <?string> Optional destination directory. Defaults to dist.
  • cleanGlobs <?string|string[]> Optional glob patterns to clean files/ directories up before every build process initiates. This is required only when the destination directory is not the dist directory. Defaults to the value of dist if unspecified.
  • copyGlobs <?string|string[]> Optional glob patterns to copy files/ directories to destination build directory. Defaults to ['<SRC>/**/*.*', '!<SRC>/**/*.ts*', '<SRC>/**/*.d.ts'].
  • ignoreGlobs <?string|string[]> Optional glob patterns to ignore files/ directories. Defaults to DEFAULT_IGNORE_GLOBS. This only works when isProd is set to true.
  • isProd <?boolean> Optional production flage. Set to true if the build process is meant for production. Defaults to process.env.NODE_ENV === 'production'.
  • rootPath <?string> Optional path to current working directory. Defaults to ..
  • babelConfig <?Object> Optional configuration for Babel. This is only needed when isProd is set to true. Defaults to DEFAULT_BABEL_CONFIG.
  • tsConfig <?string> Optional path to tsconfig.json. Defaults to ./tsconfig.json.
  • tslintConfig <?string> Optional path to tslint.json. Defaults to ./tslint.json. This defaults to ./tslint.prod.json when isProd is set to true.

builder([options])

  • options <?BuilderParams> Optional configuration for the build process.

  • returns: <Object> An object of build tasks to be assigned as Gulp task, e.g. gulp.task('<TASK_NAME>', <GULP_TASK_FUNCTION>). It comprises of a list of tasks fo a common build process with Gulp for most of the projects:

    1. clean - Always remove old files from previous build.
    2. lint - Always lint all .ts files with given tslint.json.
    3. ts - Compile all .ts files with given tsconfig.json.
    4. copy - Copy all asset files such as images, json, md, etc.
    5. watch - Run the build process by watching for flle changes.
    6. default - Default build process that comprises all the above.

License

MIT License © Rong Sen Ng

Package Sidebar

Install

npm i @messageflow/build

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

18.3 kB

Total Files

5

Last publish

Collaborators

  • motss