updeep-remeda/gulpfile.js

96 lines
2.1 KiB
JavaScript
Raw Normal View History

2017-04-19 00:55:46 +00:00
'use strict'
2017-04-19 00:47:53 +00:00
2017-04-19 00:55:46 +00:00
/* eslint strict:0, no-var:0, func-names:0 */
var path = require('path')
var gulp = require('gulp')
2017-04-19 00:55:46 +00:00
var babel = require('gulp-babel')
var eslint = require('gulp-eslint')
var mocha = require('gulp-mocha')
var rimraf = require('rimraf')
var webpack = require('webpack-stream')
2017-04-19 00:55:46 +00:00
var KarmaServer = require('karma').Server
2015-08-04 17:39:56 +00:00
2017-04-19 00:55:46 +00:00
var createWebpackConfig = require('./createWebpackConfig.js')
2015-07-31 15:53:25 +00:00
// Initialize the babel transpiler so ES2015 files gets compiled
// when they're loaded
2017-04-19 00:55:46 +00:00
require('babel-core/register')
2015-07-31 15:53:25 +00:00
2017-04-19 00:55:46 +00:00
gulp.task('clean', cb => {
rimraf('./dist', cb)
})
2015-08-02 07:48:08 +00:00
2017-04-19 00:55:46 +00:00
gulp.task('static', () =>
gulp
.src(['*.js', 'lib/**/*.js', 'test/**/*.js'])
2015-07-31 15:53:25 +00:00
.pipe(eslint())
.pipe(eslint.format())
2017-04-19 00:55:46 +00:00
.pipe(eslint.failAfterError())
)
2015-07-31 15:53:25 +00:00
2017-04-19 00:55:46 +00:00
gulp.task('test', ['test:karma', 'test:node'])
2015-08-04 17:39:56 +00:00
2017-04-19 00:55:46 +00:00
gulp.task('test:node', () =>
gulp.src('test/**/*.js').pipe(mocha({ reporter: 'dot' }))
)
2015-07-31 15:53:25 +00:00
2017-04-19 00:55:46 +00:00
gulp.task('test:karma', done => {
new KarmaServer(
{
configFile: path.join(__dirname, 'karma.conf.js'),
singleRun: true,
},
done
).start()
})
2015-08-04 17:39:56 +00:00
2017-04-19 00:55:46 +00:00
gulp.task('babel', () =>
gulp
.src('lib/**/*.js')
.pipe(babel())
.pipe(gulp.dest('dist'))
2017-04-19 00:55:46 +00:00
)
2015-07-31 15:53:25 +00:00
2017-04-19 00:47:53 +00:00
gulp.task('watch', () => {
2017-04-19 00:55:46 +00:00
gulp.start(['test:node'])
gulp.watch(['lib/**/*.js', 'test/**/*.js'], ['test:node'])
2015-08-05 15:26:44 +00:00
new KarmaServer({
configFile: path.join(__dirname, 'karma.conf.js'),
2017-04-19 00:55:46 +00:00
}).start()
})
2015-08-02 05:51:56 +00:00
2017-04-19 00:55:46 +00:00
gulp.task('webpack', ['webpack:standalone', 'webpack:standalone:min'])
2017-04-19 00:47:53 +00:00
gulp.task('webpack:standalone', () => {
2017-04-19 00:55:46 +00:00
var config = createWebpackConfig({ filename: 'updeep-standalone.js' })
2017-04-19 00:55:46 +00:00
return gulp
.src('lib/index.js')
.pipe(webpack(config))
2017-04-19 00:55:46 +00:00
.pipe(gulp.dest('dist/umd/'))
})
2017-04-19 00:47:53 +00:00
gulp.task('webpack:standalone:min', () => {
var config = createWebpackConfig({
filename: 'updeep-standalone.min.js',
minify: true,
env: 'production',
2017-04-19 00:55:46 +00:00
})
2017-04-19 00:55:46 +00:00
return gulp
.src('lib/index.js')
.pipe(webpack(config))
2017-04-19 00:55:46 +00:00
.pipe(gulp.dest('dist/umd/'))
})
2017-04-19 00:55:46 +00:00
gulp.task('build', ['babel', 'webpack'])
2017-04-19 00:55:46 +00:00
gulp.task('build:clean', ['clean'], done => {
gulp.start('build', done)
})
gulp.task('prepublish', ['build:clean'])
2017-04-19 00:55:46 +00:00
gulp.task('default', ['static', 'test'])