aboutsummaryrefslogtreecommitdiffstats
path: root/gulpfile.js
diff options
context:
space:
mode:
Diffstat (limited to 'gulpfile.js')
-rw-r--r--gulpfile.js82
1 files changed, 39 insertions, 43 deletions
diff --git a/gulpfile.js b/gulpfile.js
index 56a1e7ee..b04a38ea 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -30,6 +30,7 @@ const header = require('gulp-header');
const gitbranch = require('git-branch');
const rename = require('gulp-rename');
const replace = require('gulp-replace');
+const ansi = require('ansi-colors');
const log = require('fancy-log');
const open = require('gulp-open');
const plumber = require('gulp-plumber');
@@ -104,32 +105,14 @@ const tasks = {
css: [],
js: [],
sprite: [],
- clean: ['clean'],
+ clean: 'clean',
};
// Size plugin
const sizeOptions = { showFiles: true, gzip: true };
-// Babel config
-const babelrc = (polyfill = false) => ({
- presets: [
- [
- '@babel/preset-env',
- {
- targets: {
- browsers,
- },
- useBuiltIns: polyfill ? 'usage' : false,
- modules: false,
- },
- ],
- ],
- babelrc: false,
- exclude: 'node_modules/**',
-});
-
// Clean out /dist
-gulp.task('clean', done => {
+gulp.task(tasks.clean, done => {
const dirs = [paths.plyr.output, paths.demo.output].map(dir => path.join(dir, '**/*'));
// Don't delete the mp4
@@ -148,19 +131,34 @@ Object.entries(build.js).forEach(([filename, entry]) => {
const polyfill = filename.includes('polyfilled');
const extension = format === 'es' ? 'mjs' : 'js';
- gulp.task(name, () => {
- return gulp
+ gulp.task(name, () =>
+ gulp
.src(entry.src)
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(
rollup(
{
- plugins: [resolve(), commonjs(), babel(babelrc(polyfill))],
+ plugins: [
+ resolve(),
+ commonjs(),
+ babel({
+ presets: [
+ [
+ '@babel/env',
+ {
+ // debug: true,
+ useBuiltIns: polyfill ? 'usage' : false,
+ },
+ ],
+ ],
+ babelrc: false,
+ exclude: [/\/core-js\//],
+ }),
+ ],
},
{
name: entry.namespace,
- // exports: 'named',
format,
},
),
@@ -172,13 +170,13 @@ Object.entries(build.js).forEach(([filename, entry]) => {
}),
)
.pipe(gulp.dest(entry.dist))
- .pipe(filter(`**/*${extension}`))
+ .pipe(filter(`**/*.${extension}`))
.pipe(terser())
.pipe(rename({ suffix: minSuffix }))
.pipe(size(sizeOptions))
.pipe(sourcemaps.write(''))
- .pipe(gulp.dest(entry.dist));
- });
+ .pipe(gulp.dest(entry.dist)),
+ );
});
});
@@ -187,8 +185,8 @@ Object.entries(build.css).forEach(([filename, entry]) => {
const name = `css:${filename}`;
tasks.css.push(name);
- gulp.task(name, () => {
- return gulp
+ gulp.task(name, () =>
+ gulp
.src(entry.src)
.pipe(plumber())
.pipe(sass())
@@ -199,8 +197,8 @@ Object.entries(build.css).forEach(([filename, entry]) => {
)
.pipe(clean())
.pipe(size(sizeOptions))
- .pipe(gulp.dest(entry.dist));
- });
+ .pipe(gulp.dest(entry.dist)),
+ );
});
// SVG Sprites
@@ -208,18 +206,16 @@ Object.entries(build.sprite).forEach(([filename, entry]) => {
const name = `sprite:${filename}`;
tasks.sprite.push(name);
- log(path.basename(filename));
-
- gulp.task(name, () => {
- return gulp
+ gulp.task(name, () =>
+ gulp
.src(entry.src)
.pipe(plumber())
.pipe(imagemin())
.pipe(svgstore())
.pipe(rename({ basename: path.parse(filename).name }))
.pipe(size(sizeOptions))
- .pipe(gulp.dest(entry.dist));
- });
+ .pipe(gulp.dest(entry.dist)),
+ );
});
// Build all JS
@@ -317,7 +313,7 @@ gulp.task('version', done => {
const { domain } = deploy.cdn;
- console.log(`Updating versions to '${version}'...`);
+ log(`Uploading ${ansi.green.bold(version)} to ${ansi.cyan(domain)}...`);
// Replace versioned URLs in source
const files = ['plyr.js', 'plyr.polyfilled.js', 'config/defaults.js'];
@@ -342,7 +338,7 @@ gulp.task('cdn', done => {
throw new Error('No publisher instance. Check AWS configuration.');
}
- console.log(`Uploading '${version}' to ${domain}...`);
+ log(`Uploading ${ansi.green.bold(pkg.version)} to ${ansi.cyan(domain)}...`);
// Upload to CDN
return (
@@ -385,13 +381,13 @@ gulp.task('purge', () => {
const purge = new FastlyPurge(fastly.token);
list.forEach(url => {
- console.log(`Purging ${url}...`);
+ log(`Purging ${ansi.cyan(url)}...`);
purge.url(url, (error, result) => {
if (error) {
- console.log(error);
+ log.error(error);
} else if (result) {
- console.log(result);
+ log(result);
}
});
});
@@ -412,7 +408,7 @@ gulp.task('demo', done => {
throw new Error('No publisher instance. Check AWS configuration.');
}
- console.log(`Uploading '${version}' demo to ${deploy.demo.domain}...`);
+ log(`Uploading ${ansi.green.bold(pkg.version)} to ${ansi.cyan(domain)}...`);
// Replace versioned files in readme.md
gulp.src([`${__dirname}/readme.md`])