gulp-modern-tasks
About
A few opinionated gulp task helpers to help from having to write the same build code between projects.
API
compileJS
JS code is compiled with babel, packaged with browserify, and includes watchify.
If isProduction
is true, files will be minified, and no sourcemaps will be generated.
Browerify transforms inlcuded are: babelify. To Include more use browserify-shim and specify extra config in package.json
file.
parameters:
opts = {
files: Array<string>
: Array of files passed to browserify when creating bundle.
outPath: string
: Path built files are located at.
isProduction: bool
: Should files be built for production.
}
example:
; const opts = files: './path/to/file.js' outPath: './build/path' isProduction: false; gulp; // to start watchergulp;
compileSASS
SASS code is compiled using gulp-sass which is a wrapper for node-sass.
If isProduction
is true, files will be minified, and no sourcemaps will be generated.
parameters:
{
source: string
: Main scss file.
outPath: string
: Path built files are located at.
isProduction: bool
: Should files be built for production.
}
example:
; const opts source: './path/to/main.scss' outPath: './build/path' isProduction: false; gulp; // start a watcher as you would normallygulp;
testJS
Testing is done with gulp-mocha-phantomjs, implying tests must be written with mocha. Code is packaged and watched with browserify and watchify so code can be written in ES6.
parameters:
{
files: Array<string>
: Array of files passed to browserify when creating bundle.
outPath: string
: Path built files are located at.
runner: string
: HTML file phantomJS uses to build test environment.
}
example:
; const opts = files: './path/to/file.js' outPath: './build/path' runner: './path/to/runner.html'; gulp; // to start watchgulp;
lintJS
Linting is done with eslint and gulp-eslint.
parameters:
path: string
: Glob or string of file(s) to lint.
example:
; gulp;