Fix build
This commit is contained in:
parent
54110f8358
commit
825fd292ae
99
gulpfile.js
99
gulpfile.js
@ -30,6 +30,7 @@ const header = require('gulp-header');
|
|||||||
const gitbranch = require('git-branch');
|
const gitbranch = require('git-branch');
|
||||||
const rename = require('gulp-rename');
|
const rename = require('gulp-rename');
|
||||||
const replace = require('gulp-replace');
|
const replace = require('gulp-replace');
|
||||||
|
const ansi = require('ansi-colors');
|
||||||
const log = require('fancy-log');
|
const log = require('fancy-log');
|
||||||
const open = require('gulp-open');
|
const open = require('gulp-open');
|
||||||
const plumber = require('gulp-plumber');
|
const plumber = require('gulp-plumber');
|
||||||
@ -95,6 +96,7 @@ const paths = {
|
|||||||
path.join(__dirname, 'dist/*.svg'),
|
path.join(__dirname, 'dist/*.svg'),
|
||||||
path.join(__dirname, `demo/dist/*${minSuffix}.*`),
|
path.join(__dirname, `demo/dist/*${minSuffix}.*`),
|
||||||
path.join(__dirname, 'demo/dist/*.css'),
|
path.join(__dirname, 'demo/dist/*.css'),
|
||||||
|
path.join(__dirname, 'demo/dist/*.svg'),
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -103,32 +105,14 @@ const tasks = {
|
|||||||
css: [],
|
css: [],
|
||||||
js: [],
|
js: [],
|
||||||
sprite: [],
|
sprite: [],
|
||||||
clean: ['clean'],
|
clean: 'clean',
|
||||||
};
|
};
|
||||||
|
|
||||||
// Size plugin
|
// Size plugin
|
||||||
const sizeOptions = { showFiles: true, gzip: true };
|
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
|
// 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, '**/*'));
|
const dirs = [paths.plyr.output, paths.demo.output].map(dir => path.join(dir, '**/*'));
|
||||||
|
|
||||||
// Don't delete the mp4
|
// Don't delete the mp4
|
||||||
@ -139,10 +123,7 @@ gulp.task('clean', done => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
// JAvaScript
|
// JavaScript
|
||||||
|
|
||||||
const namespace = 'Plyr';
|
|
||||||
|
|
||||||
Object.entries(build.js).forEach(([filename, entry]) => {
|
Object.entries(build.js).forEach(([filename, entry]) => {
|
||||||
entry.formats.forEach(format => {
|
entry.formats.forEach(format => {
|
||||||
const name = `js:${filename}:${format}`;
|
const name = `js:${filename}:${format}`;
|
||||||
@ -150,19 +131,34 @@ Object.entries(build.js).forEach(([filename, entry]) => {
|
|||||||
const polyfill = filename.includes('polyfilled');
|
const polyfill = filename.includes('polyfilled');
|
||||||
const extension = format === 'es' ? 'mjs' : 'js';
|
const extension = format === 'es' ? 'mjs' : 'js';
|
||||||
|
|
||||||
gulp.task(name, () => {
|
gulp.task(name, () =>
|
||||||
return gulp
|
gulp
|
||||||
.src(entry.src)
|
.src(entry.src)
|
||||||
.pipe(plumber())
|
.pipe(plumber())
|
||||||
.pipe(sourcemaps.init())
|
.pipe(sourcemaps.init())
|
||||||
.pipe(
|
.pipe(
|
||||||
rollup(
|
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: namespace,
|
name: entry.namespace,
|
||||||
// exports: 'named',
|
|
||||||
format,
|
format,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -173,15 +169,14 @@ Object.entries(build.js).forEach(([filename, entry]) => {
|
|||||||
extname: `.${extension}`,
|
extname: `.${extension}`,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.pipe(size(sizeOptions))
|
|
||||||
.pipe(gulp.dest(entry.dist))
|
.pipe(gulp.dest(entry.dist))
|
||||||
.pipe(filter(`**/*${extension}`))
|
.pipe(filter(`**/*.${extension}`))
|
||||||
.pipe(terser())
|
.pipe(terser())
|
||||||
.pipe(rename({ suffix: minSuffix }))
|
.pipe(rename({ suffix: minSuffix }))
|
||||||
.pipe(size(sizeOptions))
|
.pipe(size(sizeOptions))
|
||||||
.pipe(sourcemaps.write(''))
|
.pipe(sourcemaps.write(''))
|
||||||
.pipe(gulp.dest(entry.dist));
|
.pipe(gulp.dest(entry.dist)),
|
||||||
});
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -190,8 +185,8 @@ Object.entries(build.css).forEach(([filename, entry]) => {
|
|||||||
const name = `css:${filename}`;
|
const name = `css:${filename}`;
|
||||||
tasks.css.push(name);
|
tasks.css.push(name);
|
||||||
|
|
||||||
gulp.task(name, () => {
|
gulp.task(name, () =>
|
||||||
return gulp
|
gulp
|
||||||
.src(entry.src)
|
.src(entry.src)
|
||||||
.pipe(plumber())
|
.pipe(plumber())
|
||||||
.pipe(sass())
|
.pipe(sass())
|
||||||
@ -202,8 +197,8 @@ Object.entries(build.css).forEach(([filename, entry]) => {
|
|||||||
)
|
)
|
||||||
.pipe(clean())
|
.pipe(clean())
|
||||||
.pipe(size(sizeOptions))
|
.pipe(size(sizeOptions))
|
||||||
.pipe(gulp.dest(entry.dist));
|
.pipe(gulp.dest(entry.dist)),
|
||||||
});
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
// SVG Sprites
|
// SVG Sprites
|
||||||
@ -211,18 +206,16 @@ Object.entries(build.sprite).forEach(([filename, entry]) => {
|
|||||||
const name = `sprite:${filename}`;
|
const name = `sprite:${filename}`;
|
||||||
tasks.sprite.push(name);
|
tasks.sprite.push(name);
|
||||||
|
|
||||||
log(path.basename(filename));
|
gulp.task(name, () =>
|
||||||
|
gulp
|
||||||
gulp.task(name, () => {
|
|
||||||
return gulp
|
|
||||||
.src(entry.src)
|
.src(entry.src)
|
||||||
.pipe(plumber())
|
.pipe(plumber())
|
||||||
.pipe(imagemin())
|
.pipe(imagemin())
|
||||||
.pipe(svgstore())
|
.pipe(svgstore())
|
||||||
.pipe(rename({ basename: path.parse(filename).name }))
|
.pipe(rename({ basename: path.parse(filename).name }))
|
||||||
.pipe(size(sizeOptions))
|
.pipe(size(sizeOptions))
|
||||||
.pipe(gulp.dest(entry.dist));
|
.pipe(gulp.dest(entry.dist)),
|
||||||
});
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Build all JS
|
// Build all JS
|
||||||
@ -268,14 +261,12 @@ const options = {
|
|||||||
cdn: {
|
cdn: {
|
||||||
headers: {
|
headers: {
|
||||||
'Cache-Control': `max-age=${maxAge}`,
|
'Cache-Control': `max-age=${maxAge}`,
|
||||||
Vary: 'Accept-Encoding',
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
demo: {
|
demo: {
|
||||||
uploadPath: branch.current === branch.beta ? 'beta' : null,
|
uploadPath: branch.current === branch.beta ? 'beta' : null,
|
||||||
headers: {
|
headers: {
|
||||||
'Cache-Control': 'no-cache, no-store, must-revalidate, max-age=0',
|
'Cache-Control': 'no-cache, no-store, must-revalidate, max-age=0',
|
||||||
Vary: 'Accept-Encoding',
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
symlinks(ver, filename) {
|
symlinks(ver, filename) {
|
||||||
@ -322,7 +313,7 @@ gulp.task('version', done => {
|
|||||||
|
|
||||||
const { domain } = deploy.cdn;
|
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
|
// Replace versioned URLs in source
|
||||||
const files = ['plyr.js', 'plyr.polyfilled.js', 'config/defaults.js'];
|
const files = ['plyr.js', 'plyr.polyfilled.js', 'config/defaults.js'];
|
||||||
@ -347,7 +338,7 @@ gulp.task('cdn', done => {
|
|||||||
throw new Error('No publisher instance. Check AWS configuration.');
|
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
|
// Upload to CDN
|
||||||
return (
|
return (
|
||||||
@ -390,13 +381,13 @@ gulp.task('purge', () => {
|
|||||||
const purge = new FastlyPurge(fastly.token);
|
const purge = new FastlyPurge(fastly.token);
|
||||||
|
|
||||||
list.forEach(url => {
|
list.forEach(url => {
|
||||||
console.log(`Purging ${url}...`);
|
log(`Purging ${ansi.cyan(url)}...`);
|
||||||
|
|
||||||
purge.url(url, (error, result) => {
|
purge.url(url, (error, result) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.log(error);
|
log.error(error);
|
||||||
} else if (result) {
|
} else if (result) {
|
||||||
console.log(result);
|
log(result);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -417,7 +408,7 @@ gulp.task('demo', done => {
|
|||||||
throw new Error('No publisher instance. Check AWS configuration.');
|
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
|
// Replace versioned files in readme.md
|
||||||
gulp.src([`${__dirname}/readme.md`])
|
gulp.src([`${__dirname}/readme.md`])
|
||||||
@ -428,7 +419,7 @@ gulp.task('demo', done => {
|
|||||||
// e.g. "../dist/plyr.js" to "https://cdn.plyr.io/x.x.x/plyr.js"
|
// e.g. "../dist/plyr.js" to "https://cdn.plyr.io/x.x.x/plyr.js"
|
||||||
const index = `${paths.demo.root}index.html`;
|
const index = `${paths.demo.root}index.html`;
|
||||||
const error = `${paths.demo.root}error.html`;
|
const error = `${paths.demo.root}error.html`;
|
||||||
const pages = [index, error];
|
const pages = [index];
|
||||||
|
|
||||||
if (branch.current === branch.master) {
|
if (branch.current === branch.master) {
|
||||||
pages.push(error);
|
pages.push(error);
|
||||||
@ -466,9 +457,11 @@ gulp.task('error', done => {
|
|||||||
|
|
||||||
// Open the demo site to check it's ok
|
// Open the demo site to check it's ok
|
||||||
gulp.task('open', () => {
|
gulp.task('open', () => {
|
||||||
|
const { domain } = deploy.demo;
|
||||||
|
|
||||||
return gulp.src(__filename).pipe(
|
return gulp.src(__filename).pipe(
|
||||||
open({
|
open({
|
||||||
uri: `https://${aws.demo.domain}/${branch.current === branch.beta ? 'beta' : ''}`,
|
uri: `https://${domain}/${branch.current === branch.beta ? 'beta' : ''}`,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
17
package.json
17
package.json
@ -27,10 +27,7 @@
|
|||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/sampotts/plyr/issues"
|
"url": "https://github.com/sampotts/plyr/issues"
|
||||||
},
|
},
|
||||||
"browserslist": [
|
"browserslist": "> 1%",
|
||||||
"> 1%",
|
|
||||||
"not dead"
|
|
||||||
],
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "gulp build",
|
"build": "gulp build",
|
||||||
"lint": "eslint src/js && npm run-script remark",
|
"lint": "eslint src/js && npm run-script remark",
|
||||||
@ -38,13 +35,13 @@
|
|||||||
"deploy": "yarn lint && gulp deploy"
|
"deploy": "yarn lint && gulp deploy"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"aws-sdk": "^2.404.0",
|
"ansi-colors": "^3.2.3",
|
||||||
|
"aws-sdk": "^2.409.0",
|
||||||
"@babel/core": "^7.3.3",
|
"@babel/core": "^7.3.3",
|
||||||
"@babel/preset-env": "^7.3.1",
|
"@babel/preset-env": "^7.3.1",
|
||||||
"babel-eslint": "^10.0.1",
|
"babel-eslint": "^10.0.1",
|
||||||
"babel-preset-minify": "^0.5.0",
|
|
||||||
"del": "^3.0.0",
|
"del": "^3.0.0",
|
||||||
"eslint": "^5.14.0",
|
"eslint": "^5.14.1",
|
||||||
"eslint-config-airbnb-base": "^13.1.0",
|
"eslint-config-airbnb-base": "^13.1.0",
|
||||||
"eslint-config-prettier": "^4.0.0",
|
"eslint-config-prettier": "^4.0.0",
|
||||||
"eslint-plugin-import": "^2.16.0",
|
"eslint-plugin-import": "^2.16.0",
|
||||||
@ -66,7 +63,7 @@
|
|||||||
"gulp-replace": "^1.0.0",
|
"gulp-replace": "^1.0.0",
|
||||||
"gulp-sass": "^4.0.2",
|
"gulp-sass": "^4.0.2",
|
||||||
"gulp-size": "^3.0.0",
|
"gulp-size": "^3.0.0",
|
||||||
"gulp-sourcemaps": "^2.6.4",
|
"gulp-sourcemaps": "^2.6.5",
|
||||||
"gulp-svgstore": "^7.0.1",
|
"gulp-svgstore": "^7.0.1",
|
||||||
"gulp-terser": "^1.1.7",
|
"gulp-terser": "^1.1.7",
|
||||||
"postcss-custom-properties": "^8.0.9",
|
"postcss-custom-properties": "^8.0.9",
|
||||||
@ -76,13 +73,13 @@
|
|||||||
"remark-validate-links": "^8.0.0",
|
"remark-validate-links": "^8.0.0",
|
||||||
"rollup-plugin-babel": "^4.3.2",
|
"rollup-plugin-babel": "^4.3.2",
|
||||||
"rollup-plugin-commonjs": "^9.2.0",
|
"rollup-plugin-commonjs": "^9.2.0",
|
||||||
"rollup-plugin-node-resolve": "^4.0.0",
|
"rollup-plugin-node-resolve": "^4.0.1",
|
||||||
"stylelint": "^9.10.1",
|
"stylelint": "^9.10.1",
|
||||||
"stylelint-config-prettier": "^4.0.0",
|
"stylelint-config-prettier": "^4.0.0",
|
||||||
"stylelint-config-recommended": "^2.1.0",
|
"stylelint-config-recommended": "^2.1.0",
|
||||||
"stylelint-config-sass-guidelines": "^5.3.0",
|
"stylelint-config-sass-guidelines": "^5.3.0",
|
||||||
"stylelint-order": "^2.0.0",
|
"stylelint-order": "^2.0.0",
|
||||||
"stylelint-scss": "^3.5.3",
|
"stylelint-scss": "^3.5.4",
|
||||||
"stylelint-selector-bem-pattern": "^2.0.0",
|
"stylelint-selector-bem-pattern": "^2.0.0",
|
||||||
"through2": "^3.0.0"
|
"through2": "^3.0.0"
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user