@messageflow/build
Quick build with Gulp
!NPMnodei-badgenodei-url
!Versionversion-badgeversion-url !Downloadsdownloads-badgedownloads-url !MIT Licensemit-license-badgemit-license-url !Code of Conductcoc-badgecoc-url
!Build Statustravis-badgetravis-url !CircleCIcircleci-badgecircleci-url !Dependency Statusdaviddm-badgedaviddm-url !NSP Statusnsp-badgensp-url !Codecovcodecov-badgecodecov-url !Coverage Statuscoveralls-badgecoveralls-url
!codebeat-badgecodebeat-url !codacy-badgecodacy-url
Better build process with Gulpgulp-url for general Node.jsnode-js-url projects written in TypeScripttypescript-url.
Table of contents
- Install - Usage- [gulpfile.js](#gulpfilejs)
- DEFAULTIGNOREGLOBS
- DEFAULTBABELCONFIG
- BuilderParams
- builder(options)Pre-requisites
- Node.jsnode-js-url >= 8.9.0
- NPMnpm-url >= 5.5.1 (NPMnpm-url comes with Node.jsnode-js-url so there is no need to install separately.)
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
DEFAULTIGNOREGLOBS
[
'!**/demo*/**/*.ts*',
'!**/test*/**/*.ts*',
]
DEFAULTBABELCONFIG
{
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
<?stringstring-mdn-url> Optional source directory. Defaults tosrc
.dist
<?stringstring-mdn-url> Optional destination directory. Defaults todist
.cleanGlobs
<?stringstring-mdn-url|stringstring-mdn-url> Optional glob patterns to clean files/ directories up before every build process initiates. This is required only when the destination directory is not thedist
directory. Defaults to the value ofdist
if unspecified.copyGlobs
<?stringstring-mdn-url|stringstring-mdn-url> Optional glob patterns to copy files/ directories to destination build directory. Defaults to['<SRC>/**/*.*', '!<SRC>/**/*.ts*', '<SRC>/**/*.d.ts']
.ignoreGlobs
<?stringstring-mdn-url|stringstring-mdn-url> Optional glob patterns to ignore files/ directories. Defaults to DEFAULTIGNOREGLOBSdefault-ignore-globs-url. This only works whenisProd
is set to true.isProd
<?booleanboolean-mdn-url> Optional production flage. Set totrue
if the build process is meant for production. Defaults toprocess.env.NODE_ENV === 'production'
.rootPath
<?stringstring-mdn-url> Optional path to current working directory. Defaults to.
.babelConfig
<?Objectobject-mdn-url> Optional configuration for Babelbabel-url. This is only needed whenisProd
is set to true. Defaults to DEFAULTBABELCONFIGdefault-babel-config-url.tsConfig
<?stringstring-mdn-url> Optional path totsconfig.json
. Defaults to./tsconfig.json
.tslintConfig
<?stringstring-mdn-url> Optional path totslint.json
. Defaults to./tslint.json
. This defaults to./tslint.prod.json
whenisProd
is set to true.
builder(options)
options
<?BuilderParamsbuilderparams-url> Optional configuration for the build process.- returns: <Objectobject-mdn-url> An object of build tasks to be assigned as Gulpgulp-url 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.