1
0
mirror of https://github.com/videojs/video.js.git synced 2025-01-06 06:50:51 +02:00
video.js/Gruntfile.js

385 lines
10 KiB
JavaScript
Raw Normal View History

module.exports = function(grunt) {
var pkg, s3, version, verParts;
2013-05-04 09:05:33 +03:00
pkg = grunt.file.readJSON('package.json');
verParts = pkg.version.split('.');
version = {
full: pkg.version,
major: verParts[0],
minor: verParts[1],
patch: verParts[2]
};
version.majorMinor = version.major + '.' + version.minor;
grunt.vjsVersion = version;
// loading predefined source order from source-loader.js
// trust me, this is the easist way to do it so far
/*jshint undef:false, evil:true */
var blockSourceLoading = true;
var sourceFiles; // Needed to satisfy jshint
eval(grunt.file.read('./build/source-loader.js'));
grunt.sourceFiles = sourceFiles;
// Project configuration.
grunt.initConfig({
pkg: pkg,
2013-01-13 09:23:22 +03:00
build: {
src: 'src/js/dependencies.js',
options: {
baseDir: 'src/js/'
}
},
clean: {
build: ['build/files/*'],
dist: ['dist/*']
},
jshint: {
2013-01-13 09:23:22 +03:00
src: {
src: ['src/js/**/*.js', 'Gruntfile.js', 'test/unit/**/*.js'],
options: {
2013-02-09 01:08:31 +03:00
jshintrc: '.jshintrc'
}
}
},
minify: {
source:{
src: ['build/files/combined.video.js', 'build/compiler/goog.base.js', 'src/js/exports.js'],
externs: ['src/js/player.externs.js', 'src/js/media/flash.externs.js'],
dest: 'build/files/minified.video.js'
2013-01-13 09:23:22 +03:00
},
tests: {
src: ['build/files/combined.video.js', 'build/compiler/goog.base.js', 'src/js/exports.js', 'test/unit/*.js'],
Better error handling. closes #1197 Squashed commit of the following: commit 81d785980d3f3e4c1025f7b421f0ecb7320469f1 Author: Steve Heffernan <steve@zencoder.com> Date: Mon May 12 12:53:59 2014 -0700 Removed unneeded comments commit c7ad7322e49df9cb22665692dbfe615dfa44758f Author: Steve Heffernan <steve@zencoder.com> Date: Fri May 9 14:29:31 2014 -0700 Addressed comments in #1191 Now clearing errors on loadstart events. Added some default error messages. commit a742239d0e799fa6a5fee056cc37b3c2e3ab4510 Author: Steve Heffernan <steve@zencoder.com> Date: Wed May 7 15:38:31 2014 -0700 Fixed the error display to hide by default commit 561c3f844956db6f532cae8ed81a86cc39b10db1 Author: Steve Heffernan <steve@zencoder.com> Date: Mon May 5 10:44:47 2014 -0700 Added support for displaying a message for the error. commit 22142078427ead85548c4755bf1943a0a07b22b4 Author: Steve Heffernan <steve@zencoder.com> Date: Fri May 2 17:18:22 2014 -0700 Updated spinner to hide on all errors commit 95d7e7027467cf96b14db6692d93c7c7f41c5810 Author: Steve Heffernan <steve@zencoder.com> Date: Fri May 2 15:37:44 2014 -0700 Exported ErrorDisplay commit 11ca9cdd8db4d1559f5d1908c4e67be32ca7a25e Author: Steve Heffernan <steve@zencoder.com> Date: Fri May 2 15:35:46 2014 -0700 Updated flash tech to support new errors commit 56cbe66f4233e54f13550367590864102f5de0fe Author: Steve Heffernan <steve@zencoder.com> Date: Fri May 2 13:06:49 2014 -0700 Started on better error handling and displaying in the UI when an error has occurred. commit 740014c57b264079cf4084965a9384b49a7c0f64 Author: Steve Heffernan <steve@zencoder.com> Date: Wed Apr 30 16:11:33 2014 -0700 Added better global log/error/warn functions. Added sinon.js for stubs in tests. Updated grunt version to satisfy peer dependency warning.
2014-05-13 03:08:48 +03:00
externs: ['src/js/player.externs.js', 'src/js/media/flash.externs.js', 'test/qunit-externs.js', 'test/sinon-externs.js'],
dest: 'build/files/test.minified.video.js'
2013-01-13 09:23:22 +03:00
}
},
dist: {},
qunit: {
source: ['test/index.html'],
minified: ['test/minified.html'],
minified_api: ['test/minified-api.html']
},
watch: {
2013-07-20 06:18:39 +03:00
files: [ 'src/**/*', 'test/unit/*.js', 'Gruntfile.js' ],
2013-02-09 01:08:31 +03:00
tasks: 'dev'
2013-05-04 09:05:33 +03:00
},
2014-03-26 01:22:29 +03:00
connect: {
dev: {
options: {
port: 9999,
keepalive: true
}
}
},
2013-05-04 09:05:33 +03:00
copy: {
minor: {
files: [
{expand: true, cwd: 'build/files/', src: ['*'], dest: 'dist/'+version.majorMinor+'/', filter: 'isFile'} // includes files in path
]
},
patch: {
files: [
{expand: true, cwd: 'build/files/', src: ['*'], dest: 'dist/'+version.full+'/', filter: 'isFile'} // includes files in path
]
}
},
s3: {
options: {
key: process.env.VJS_S3_KEY,
secret: process.env.VJS_S3_SECRET,
bucket: process.env.VJS_S3_BUCKET,
access: 'public-read'
},
minor: {
2013-05-04 09:05:33 +03:00
upload: [
{
src: 'dist/cdn/*',
dest: 'vjs/'+version.majorMinor+'/',
rel: 'dist/cdn/',
headers: {
'Cache-Control': 'public, max-age=2628000'
}
}
]
},
patch: {
upload: [
{
src: 'dist/cdn/*',
dest: 'vjs/'+version.full+'/',
rel: 'dist/cdn/',
headers: {
'Cache-Control': 'public, max-age=31536000'
}
2013-05-04 09:05:33 +03:00
}
]
}
},
fastly: {
options: {
key: process.env.VJS_FASTLY_API_KEY
},
minor: {
options: {
host: 'vjs.zencdn.net',
urls: [
version.majorMinor+'/*'
]
}
},
patch: {
options: {
host: 'vjs.zencdn.net',
urls: [
version.full+'/*'
]
}
}
},
cssmin: {
minify: {
expand: true,
cwd: 'build/files/',
src: ['video-js.css'],
dest: 'build/files/',
ext: '.min.css'
}
2013-07-20 06:18:39 +03:00
},
less: {
dev: {
files: {
'build/files/video-js.css': 'src/css/video-js.less'
}
}
},
karma: {
// this config file applies to all following configs except if overwritten
options: {
configFile: 'test/karma.conf.js'
},
// this only runs on PRs from the mainrepo on saucelabs
saucelabs: {
browsers: ['chrome_sl']
},
chrome_sl: {
browsers: ['chrome_sl']
},
firefox_sl: {
browsers: ['firefox_sl']
},
safari_sl: {
browsers: ['safari_sl']
},
ipad_sl: {
browsers: ['ipad_sl']
},
android_sl: {
browsers: ['android_sl']
},
ie_sl: {
browsers: ['ie_sl']
},
// these are run locally on local browsers
dev: {
browsers: ['Chrome', 'Firefox', 'Safari']
},
chromecanary: {
browsers: ['ChromeCanary']
},
chrome: {
browsers: ['Chrome']
},
firefox: {
browsers: ['Firefox']
},
safari: {
browsers: ['Safari']
},
ie: {
browsers: ['IE']
},
phantomjs: {
browsers: ['PhantomJS']
},
// This is all the minified tests run locally on local browsers
minified_dev: {
browsers: ['Chrome', 'Firefox', 'Safari'],
configFile: 'test/karma.minified.conf.js'
},
minified_chromecanary: {
browsers: ['ChromeCanary'],
configFile: 'test/karma.minified.conf.js'
},
minified_chrome: {
browsers: ['Chrome'],
configFile: 'test/karma.minified.conf.js'
},
minified_firefox: {
browsers: ['Firefox'],
configFile: 'test/karma.minified.conf.js'
},
minified_safari: {
browsers: ['Safari'],
configFile: 'test/karma.minified.conf.js'
},
minified_ie: {
browsers: ['IE'],
configFile: 'test/karma.minified.conf.js'
},
minified_phantomjs: {
browsers: ['PhantomJS'],
configFile: 'test/karma.minified.conf.js'
},
// This is all the minified api tests run locally on local browsers
minified_api_dev: {
browsers: ['Chrome', 'Firefox', 'Safari'],
configFile: 'test/karma.minified.api.conf.js'
},
minified_api_chromecanary: {
browsers: ['ChromeCanary'],
configFile: 'test/karma.minified.api.conf.js'
},
minified_api_chrome: {
browsers: ['Chrome'],
configFile: 'test/karma.minified.api.conf.js'
},
minified_api_firefox: {
browsers: ['Firefox'],
configFile: 'test/karma.minified.api.conf.js'
},
minified_api_safari: {
browsers: ['Safari'],
configFile: 'test/karma.minified.api.conf.js'
},
minified_api_ie: {
browsers: ['IE'],
configFile: 'test/karma.minified.api.conf.js'
},
minified_api_phantomjs: {
browsers: ['PhantomJS'],
configFile: 'test/karma.minified.api.conf.js'
}
},
vjsdocs: {
all: {
src: sourceFiles,
dest: 'docs/api',
options: {
baseURL: 'https://github.com/videojs/video.js/blob/master/'
}
}
2014-01-16 22:25:07 +03:00
},
vjslanguages: {
defaults: {
files: {
'build/files/lang': ['lang/*.json']
}
}
},
2014-01-16 22:25:07 +03:00
zip: {
dist: {
router: function (filepath) {
var path = require('path');
return path.relative('dist', filepath);
},
2014-03-07 00:15:53 +03:00
// compression: 'DEFLATE',
2014-01-16 22:25:07 +03:00
src: ['dist/video-js/**/*'],
dest: 'dist/video-js-' + version.full + '.zip'
}
2014-02-14 08:09:42 +03:00
},
usebanner: {
dist: {
options: {
position: 'top',
banner: '/*! Video.js v' + version.full + ' <%= pkg.copyright %> */ ',
linebreak: true
},
files: {
src: [ 'build/files/minified.video.js']
}
}
},
version: {
options: {
pkg: 'package.json'
},
major: {
options: {
release: 'major'
},
src: ['package.json', 'bower.json', 'component.json']
},
minor: {
options: {
release: 'minor'
},
src: ['package.json', 'bower.json', 'component.json']
},
patch: {
options: {
release: 'patch'
},
src: ['package.json', 'bower.json', 'component.json']
}
},
'github-release': {
options: {
repository: 'videojs/video.js',
auth: {
user: process.env.VJS_GITHUB_USER,
password: process.env.VJS_GITHUB_TOKEN
},
release: {
tag_name: 'v'+ version.full,
name: version.full,
body: require('chg').find(version.full).changesRaw
}
},
files: {
src: ['dist/video-js-'+ version.full +'.zip'] // Files that you want to attach to Release
}
}
});
grunt.loadNpmTasks('grunt-videojs-languages');
2014-03-26 01:22:29 +03:00
grunt.loadNpmTasks('grunt-contrib-connect');
2013-02-09 01:08:31 +03:00
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-cssmin');
2013-07-20 06:18:39 +03:00
grunt.loadNpmTasks('grunt-contrib-less');
2013-05-04 09:05:33 +03:00
grunt.loadNpmTasks('grunt-s3');
2013-03-26 02:52:36 +03:00
grunt.loadNpmTasks('contribflow');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('videojs-doc-generator');
2014-01-16 22:25:07 +03:00
grunt.loadNpmTasks('grunt-zip');
grunt.loadNpmTasks('grunt-banner');
grunt.loadNpmTasks('grunt-version');
grunt.loadNpmTasks('chg');
grunt.loadNpmTasks('grunt-fastly');
grunt.loadNpmTasks('grunt-github-releaser');
// grunt.loadTasks('./docs/tasks/');
// grunt.loadTasks('../videojs-doc-generator/tasks/');
grunt.registerTask('pretask', ['jshint', 'less', 'vjslanguages', 'build', 'minify', 'vttjs', 'usebanner']);
2013-01-13 09:23:22 +03:00
// Default task.
grunt.registerTask('default', ['pretask', 'dist']);
2013-01-13 09:23:22 +03:00
// Development watch task
grunt.registerTask('dev', ['jshint', 'less', 'vjslanguages', 'build', 'qunit:source']);
grunt.registerTask('test-qunit', ['pretask', 'qunit']);
2014-01-16 22:25:07 +03:00
grunt.registerTask('dist', 'Creating distribution', ['dist-copy', 'zip:dist']);
// Load all the tasks in the tasks directory
grunt.loadTasks('tasks');
};