Skip to content

Commit

Permalink
@misteroneill Add browserify:dist Target. Fix vtt.js URL.. closes #2741
Browse files Browse the repository at this point in the history
  • Loading branch information
misteroneill authored and gkatsev committed Oct 28, 2015
1 parent 42e33ca commit e6f5d6b
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 35 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ CHANGELOG
* @Soviut Fixed argument names in some API docs ([view](https://github.com/videojs/video.js/pull/2714))
* @forbesjo Added Microsoft Caption Maker link ([view](https://github.com/videojs/video.js/pull/2618))
* @misteroneill updated modal dialog CSS ([view](https://github.com/videojs/video.js/pull/2756))
* @misteroneill Add browserify

--------------------

Expand Down
128 changes: 93 additions & 35 deletions build/grunt.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,85 @@ module.exports = function(grunt) {
patch: verParts[2]
};

const browserifyGruntDefaults = {
browserifyOptions: {
debug: true,
standalone: 'videojs'
},
plugin: [
['browserify-derequire']
],
transform: [
require('babelify').configure({
sourceMapRelative: './',
loose: ['all']
}),
['browserify-versionify', {
placeholder: '__VERSION__',
version: pkg.version
}],
['browserify-versionify', {
placeholder: '__VERSION_NO_PATCH__',
version: version.majorMinor
}],
['browserify-versionify', {
placeholder: '__SWF_VERSION__',
version: pkg.dependencies['videojs-swf']
}]
]
};

/**
* Customizes _.merge behavior in `browserifyGruntOptions` to concatenate
* arrays. This can be overridden on a per-call basis to
*
* @see https://lodash.com/docs#merge
* @function browserifyGruntCustomizer
* @private
* @param {Mixed} objectValue
* @param {Mixed} sourceValue
* @return {Object}
*/
function browserifyGruntCustomizer(objectValue, sourceValue) {
if (Array.isArray(objectValue)) {
return objectValue.concat(sourceValue);
}
}

/**
* Creates a unique object of Browserify Grunt task options.
*
* @function browserifyGruntOptions
* @private
* @param {Object} [options]
* @param {Function} [customizer=browserifyGruntCustomizer]
* If the default array-concatenation behavior is not desireable,
* pass _.noop or a unique customizer (https://lodash.com/docs#merge).
*
* @return {Object}
*/
function browserifyGruntOptions(options = null, customizer = browserifyGruntCustomizer) {
return _.merge({}, browserifyGruntDefaults, options, customizer);
}

/**
* Creates processor functions for license banners.
*
* @function createLicenseProcessor
* @private
* @param {Object} data Custom data overriding `bannerCommonData`. Will
* not be mutated.
* @return {Function} A function which returns a processed grunt template
* using an object constructed from `bannerCommonData`
* and the `data` argument.
*/
let createLicenseProcessor = (data) => function () {
return grunt.template.process(license, {
data: _.merge({}, bannerCommonData, data)
});
};
function createLicenseProcessor(data) {
return () => {
return grunt.template.process(license, {
data: _.merge({}, bannerCommonData, data)
});
};
}

version.majorMinor = `${version.major}.${version.minor}`;
grunt.vjsVersion = version;
Expand Down Expand Up @@ -242,38 +306,25 @@ module.exports = function(grunt) {
}
},
browserify: {
options: {
browserifyOptions: {
debug: true,
standalone: 'videojs'
},
plugin: [
['browserify-derequire']
],
transform: [
require('babelify').configure({
sourceMapRelative: './',
loose: ['all']
}),
['browserify-versionify', {
placeholder: '__VERSION__',
version: pkg.version
}],
['browserify-versionify', {
placeholder: '__VERSION_NO_PATCH__',
version: version.majorMinor
}],
['browserify-versionify', {
placeholder: '__SWF_VERSION__',
version: pkg.dependencies['videojs-swf']
}]
]
},
options: browserifyGruntOptions(),
build: {
files: {
'build/temp/video.js': ['src/js/video.js']
}
},
dist: {
options: browserifyGruntOptions({
transform: [
['browserify-versionify', {
placeholder: '../node_modules/vtt.js/dist/vtt.js',
version: 'https://cdn.rawgit.com/gkatsev/vtt.js/vjs-v0.12.1/dist/vtt.min.js'
}],
]
}),
files: {
'build/temp/video.js': ['src/js/video.js']
}
},
watch: {
options: {
watch: true,
Expand Down Expand Up @@ -380,7 +431,7 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('videojs-doc-generator');
grunt.loadNpmTasks('chg');

grunt.registerTask('build', [
const buildDependents = [
'clean:build',

'jshint',
Expand All @@ -400,11 +451,18 @@ module.exports = function(grunt) {
'copy:swf',
'copy:ie8',
'vjslanguages'
]);
];

grunt.registerTask('build', buildDependents);

grunt.registerTask(
'build:dist',
buildDependents.map(task => task === 'browserify:build' ? 'browserify:dist' : task)
);

grunt.registerTask('dist', [
'clean:dist',
'build',
'build:dist',
'copy:dist',
'copy:examples',
'zip:dist'
Expand Down

0 comments on commit e6f5d6b

Please sign in to comment.