@hidoo/gulp-task-build-js-browserify
Task that build javascript by browserify for gulp.
Installation
$ npm install --save-dev gulp@next @babel/{core,polyfill,preset-env} @hidoo/gulp-task-build-js-browserify
Usage
import {task} from 'gulp';
import buildJs from '@hidoo/gulp-task-build-js-browserify';
task('js', buildJs({
src: '/path/to/js/main.js',
dest: '/path/to/dest'
}));
API
buildJs
return javascript build task by browserify
Parameters
-
options
Object options (optional, default{}
)-
options.name
String task name (use as displayName) (optional, default'build:js'
) -
options.src
String source path -
options.dest
String destination path -
options.filename
String destination filename (optional, default'main.js'
) -
options.suffix
String suffix when compressed (optional, default'.min'
) -
options.targets
Array<String>? target browsers. see: default target browsers -
options.browsers
Array<String>? alias of options.targets. -
options.useBuiltIns
(String | Boolean) use polyfill or not. see: useBuiltIns in @babel/preset-env (optional, default'usage'
) -
options.corejs
(Number | String | Object) specify core-js version (Recommend setting with options.useBuiltIns: 'entry') see: corejs in @babel/preset-env (optional, default3
) -
options.babelrc
String babelrc path (optional, defaultpath.resolve(process.cwd(),'.babelrc.js')
) -
options.compress
Boolean compress file or not (optional, defaultfalse
) -
options.verbose
Boolean out log or not (optional, defaultfalse
)
-
Examples
import {task} from 'gulp';
import buildJs from '@hidoo/gulp-task-build-js-browserify';
task('js', buildJs({
name: 'js:main',
src: '/path/to/js/main.js',
dest: '/path/to/dest',
filename: 'main.js',
suffix: '.hoge',
targets: ['> 0.1% in JP'],
useBuiltIns: false,
corejs: 2,
babelrc: '/path/to/.babelrc.js',
compress: true,
verbose: true
}));
Test
$ yarn test
License
MIT