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 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');
|
||||
@ -95,6 +96,7 @@ const paths = {
|
||||
path.join(__dirname, 'dist/*.svg'),
|
||||
path.join(__dirname, `demo/dist/*${minSuffix}.*`),
|
||||
path.join(__dirname, 'demo/dist/*.css'),
|
||||
path.join(__dirname, 'demo/dist/*.svg'),
|
||||
],
|
||||
};
|
||||
|
||||
@ -103,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
|
||||
@ -139,10 +123,7 @@ gulp.task('clean', done => {
|
||||
done();
|
||||
});
|
||||
|
||||
// JAvaScript
|
||||
|
||||
const namespace = 'Plyr';
|
||||
|
||||
// JavaScript
|
||||
Object.entries(build.js).forEach(([filename, entry]) => {
|
||||
entry.formats.forEach(format => {
|
||||
const name = `js:${filename}:${format}`;
|
||||
@ -150,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: namespace,
|
||||
// exports: 'named',
|
||||
name: entry.namespace,
|
||||
format,
|
||||
},
|
||||
),
|
||||
@ -173,15 +169,14 @@ Object.entries(build.js).forEach(([filename, entry]) => {
|
||||
extname: `.${extension}`,
|
||||
}),
|
||||
)
|
||||
.pipe(size(sizeOptions))
|
||||
.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)),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@ -190,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())
|
||||
@ -202,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
|
||||
@ -211,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
|
||||
@ -268,14 +261,12 @@ const options = {
|
||||
cdn: {
|
||||
headers: {
|
||||
'Cache-Control': `max-age=${maxAge}`,
|
||||
Vary: 'Accept-Encoding',
|
||||
},
|
||||
},
|
||||
demo: {
|
||||
uploadPath: branch.current === branch.beta ? 'beta' : null,
|
||||
headers: {
|
||||
'Cache-Control': 'no-cache, no-store, must-revalidate, max-age=0',
|
||||
Vary: 'Accept-Encoding',
|
||||
},
|
||||
},
|
||||
symlinks(ver, filename) {
|
||||
@ -322,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'];
|
||||
@ -347,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 (
|
||||
@ -390,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);
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -417,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`])
|
||||
@ -428,7 +419,7 @@ gulp.task('demo', done => {
|
||||
// e.g. "../dist/plyr.js" to "https://cdn.plyr.io/x.x.x/plyr.js"
|
||||
const index = `${paths.demo.root}index.html`;
|
||||
const error = `${paths.demo.root}error.html`;
|
||||
const pages = [index, error];
|
||||
const pages = [index];
|
||||
|
||||
if (branch.current === branch.master) {
|
||||
pages.push(error);
|
||||
@ -466,9 +457,11 @@ gulp.task('error', done => {
|
||||
|
||||
// Open the demo site to check it's ok
|
||||
gulp.task('open', () => {
|
||||
const { domain } = deploy.demo;
|
||||
|
||||
return gulp.src(__filename).pipe(
|
||||
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": {
|
||||
"url": "https://github.com/sampotts/plyr/issues"
|
||||
},
|
||||
"browserslist": [
|
||||
"> 1%",
|
||||
"not dead"
|
||||
],
|
||||
"browserslist": "> 1%",
|
||||
"scripts": {
|
||||
"build": "gulp build",
|
||||
"lint": "eslint src/js && npm run-script remark",
|
||||
@ -38,13 +35,13 @@
|
||||
"deploy": "yarn lint && gulp deploy"
|
||||
},
|
||||
"devDependencies": {
|
||||
"aws-sdk": "^2.404.0",
|
||||
"ansi-colors": "^3.2.3",
|
||||
"aws-sdk": "^2.409.0",
|
||||
"@babel/core": "^7.3.3",
|
||||
"@babel/preset-env": "^7.3.1",
|
||||
"babel-eslint": "^10.0.1",
|
||||
"babel-preset-minify": "^0.5.0",
|
||||
"del": "^3.0.0",
|
||||
"eslint": "^5.14.0",
|
||||
"eslint": "^5.14.1",
|
||||
"eslint-config-airbnb-base": "^13.1.0",
|
||||
"eslint-config-prettier": "^4.0.0",
|
||||
"eslint-plugin-import": "^2.16.0",
|
||||
@ -66,7 +63,7 @@
|
||||
"gulp-replace": "^1.0.0",
|
||||
"gulp-sass": "^4.0.2",
|
||||
"gulp-size": "^3.0.0",
|
||||
"gulp-sourcemaps": "^2.6.4",
|
||||
"gulp-sourcemaps": "^2.6.5",
|
||||
"gulp-svgstore": "^7.0.1",
|
||||
"gulp-terser": "^1.1.7",
|
||||
"postcss-custom-properties": "^8.0.9",
|
||||
@ -76,13 +73,13 @@
|
||||
"remark-validate-links": "^8.0.0",
|
||||
"rollup-plugin-babel": "^4.3.2",
|
||||
"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-config-prettier": "^4.0.0",
|
||||
"stylelint-config-recommended": "^2.1.0",
|
||||
"stylelint-config-sass-guidelines": "^5.3.0",
|
||||
"stylelint-order": "^2.0.0",
|
||||
"stylelint-scss": "^3.5.3",
|
||||
"stylelint-scss": "^3.5.4",
|
||||
"stylelint-selector-bem-pattern": "^2.0.0",
|
||||
"through2": "^3.0.0"
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user