-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
37 lines (32 loc) · 924 Bytes
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* eslint-env node */
const gulp = require('gulp');
const _ = require('lodash');
const babel = require('gulp-babel');
const webpack = require('webpack');
const del = require('del');
const pify = require('pify');
const webpackConfig = require('./webpack.config.js');
gulp.task('default', ['compile', 'build']);
gulp.task('compile', ['clean'], () =>
gulp.src('src/*.js').
pipe(babel()).
pipe(gulp.dest('lib'))
);
gulp.task('build', ['clean'], () => {
const minifiedWebpackConfig = _.cloneDeep(webpackConfig);
minifiedWebpackConfig.output.filename =
minifiedWebpackConfig.output.filename.replace('.js', '.min.js');
minifiedWebpackConfig.plugins = [
new webpack.optimize.UglifyJsPlugin({minimize: true})
];
return Promise.all([
pify(webpack)(webpackConfig),
pify(webpack)(minifiedWebpackConfig),
]);
});
gulp.task('clean', () => {
return del([
'dist/**',
'lib/**',
]);
});