1
0
mirror of https://github.com/videojs/video.js.git synced 2024-11-24 08:42:25 +02:00
video.js/Gruntfile.js

378 lines
9.8 KiB
JavaScript
Raw Normal View History

module.exports = function(grunt) {
var pkg = grunt.file.readJSON('package.json');
var license = grunt.file.read('build/license-header.txt');
var verParts = pkg.version.split('.');
var version = {
2013-05-04 09:05:33 +03:00
full: pkg.version,
major: verParts[0],
minor: verParts[1],
patch: verParts[2]
};
2013-05-04 09:05:33 +03:00
version.majorMinor = version.major + '.' + version.minor;
grunt.vjsVersion = version;
// Project configuration.
grunt.initConfig({
pkg: pkg,
clean: {
build: ['build/temp/*'],
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'
}
}
},
uglify: {
options: {
sourceMap: true,
sourceMapIn: 'build/temp/video.js.map',
sourceMapRoot: '../../src/js',
preserveComments: 'some',
mangle: true,
compress: {
sequences: true,
dead_code: true,
conditionals: true,
booleans: true,
unused: true,
if_return: true,
join_vars: true,
drop_console: true
}
},
build: {
files: {
'build/temp/video.min.js': 'build/temp/video.js'
}
2013-01-13 09:23:22 +03:00
}
},
dist: {},
watch: {
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/temp/', src: ['*'], dest: 'dist/'+version.majorMinor+'/', filter: 'isFile'} // includes files in path
2013-05-04 09:05:33 +03:00
]
},
patch: {
files: [
{expand: true, cwd: 'build/temp/', src: ['*'], dest: 'dist/'+version.full+'/', filter: 'isFile'} // includes files in path
2013-05-04 09:05:33 +03:00
]
},
fonts: { expand: true, cwd: 'src/css/font/', src: ['*'], dest: 'build/temp/font/', filter: 'isFile' },
swf: { src: './node_modules/videojs-swf/dist/video-js.swf', dest: './build/temp/video-js.swf' },
novtt: { src: './build/temp/video.js', dest: './build/temp/alt/video.novtt.js' },
dist: { expand: true, cwd: 'build/temp/', src: ['**/**'], dest: 'dist/', filter: 'isFile' },
examples: { expand: true, cwd: 'build/examples/', src: ['**/**'], dest: 'dist/examples/', filter: 'isFile' },
cdn: { expand: true, cwd: 'dist/', src: ['**/**'], dest: 'dist/cdn/', filter: 'isFile' },
2013-05-04 09:05:33 +03:00
},
aws_s3: {
options: {
accessKeyId: process.env.VJS_S3_KEY,
secretAccessKey: process.env.VJS_S3_SECRET,
bucket: process.env.VJS_S3_BUCKET,
access: 'public-read',
uploadConcurrency: 5
},
patch: {
files: [
2013-05-04 09:05:33 +03:00
{
expand: true,
cwd: 'dist/cdn/',
src: ['**'],
dest: 'vjs/'+version.full+'/',
params: { CacheControl: 'public, max-age=31536000' }
}
]
},
minor: {
files: [
{
expand: true,
cwd: 'dist/cdn/',
src: ['**'],
dest: 'vjs/'+version.majorMinor+'/',
params: { CacheControl: 'public, max-age=2628000' }
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/temp/',
src: ['video-js.css'],
dest: 'build/temp/',
ext: '.min.css'
}
2013-07-20 06:18:39 +03:00
},
less: {
dev: {
files: {
'build/temp/video-js.css': 'src/css/video-js.less'
2013-07-20 06:18:39 +03:00
}
}
},
karma: {
// this config file applies to all following configs except if overwritten
options: {
configFile: 'test/karma.conf.js'
},
// 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 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'] }
},
vjsdocs: {
all: {
// TODO: Update vjsdocs to support new build, or switch to jsdoc
src: '',
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/temp/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',
src: ['dist/**/*'],
2014-01-16 22:25:07 +03:00
dest: 'dist/video-js-' + version.full + '.zip'
}
2014-02-14 08:09:42 +03:00
},
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']
},
css: {
options: {
prefix: '@version\\s*'
},
src: 'build/temp/video-js.css'
}
},
'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
}
},
browserify: {
build: {
files: {
'build/temp/video.js': ['src/js/video.js']
},
options: {
browserifyOptions: {
debug: true,
standalone: 'videojs'
},
banner: license,
transform: [
require('babelify').configure({
sourceMapRelative: './src/js'
}),
['browserify-versionify', {
placeholder: '__VERSION__',
version: pkg.version
}],
['browserify-versionify', {
placeholder: '__VERSION_NO_PATCH__',
version: version.majorMinor
}]
]
}
}
},
exorcise: {
build: {
options: {},
files: {
'build/temp/video.js.map': ['build/temp/video.js'],
}
}
},
coveralls: {
all: {
src: 'test/coverage/lcov.info'
}
},
concat: {
vtt: {
options: {
separator: '\n',
},
src: ['build/temp/video.js', 'node_modules/vtt.js/dist/vtt.js'],
dest: 'build/temp/video.js',
},
}
});
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-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');
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.loadNpmTasks('grunt-aws-s3');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-coveralls');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-exorcise');
grunt.registerTask('build', [
'clean:build',
'jshint',
'browserify',
'copy:novtt',
'concat:vtt',
'exorcise',
'uglify',
'less',
'version:css',
'cssmin',
'copy:fonts',
'copy:swf',
'vjslanguages'
]);
grunt.registerTask('dist', [
'clean:dist',
'build',
'copy:dist',
'copy:examples',
'zip:dist'
]);
grunt.registerTask('cdn', [
'dist',
'copy:cdn',
'dist-cdn'
]);
// Remove this and add to the test task once mmcc's coverall changes are merged
grunt.registerTask('newtest', ['build', 'karma:chrome']);
2013-01-13 09:23:22 +03:00
// Default task.
grunt.registerTask('default', ['build', 'test']);
// Development watch task. Doing the minimum required.
grunt.registerTask('dev', ['jshint', 'less', 'browserify', 'karma:chrome']);
2014-01-16 22:25:07 +03:00
// Tests.
// We want to run things a little differently if it's coming from Travis vs local
if (process.env.TRAVIS) {
grunt.registerTask('test', ['build', 'test-travis', 'coveralls']);
} else {
grunt.registerTask('test', ['build', 'test-local']);
}
// Load all the tasks in the tasks directory
grunt.loadTasks('build/tasks');
};