Skip to content

Commit

Permalink
Add a Grunt (and npm) build process, with instructions in README.md (…
Browse files Browse the repository at this point in the history
…and removed compile.sh)
  • Loading branch information
OwenEdwards committed Dec 27, 2014
1 parent fc9ba4d commit e8c5339
Show file tree
Hide file tree
Showing 5 changed files with 149 additions and 22 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.DS_Store
thirdparty/jwplayer.*
node_modules/
101 changes: 101 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
module.exports = function(grunt) {

grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks("grunt-remove-logging");
grunt.loadNpmTasks('grunt-contrib-jshint');

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
build: {
src: [
// Ultimately this should be just 'scripts/*.js',
// but for now we're maintaining the order which was
// specified in the previous 'compile.sh' script
'scripts/ableplayer-base.js',
'scripts/initialize.js',
'scripts/preference.js',
'scripts/webvtt.js',
'scripts/buildplayer.js',
'scripts/track.js',
'scripts/seekbar.js',
'scripts/dialog.js',
'scripts/misc.js',
'scripts/description.js',
'scripts/browser.js',
'scripts/control.js',
'scripts/caption.js',
'scripts/metadata.js',
'scripts/translation.js',
'scripts/transcript.js',
'scripts/search.js',
'scripts/event.js'
],
dest: 'build/<%= pkg.name %>.js'
},
},
removelogging: {
dist: {
src: [
'build/<%= pkg.name %>.js'
],
dest: 'build/<%= pkg.name %>.dist.js'
},
options: {
// Remove all console output (see https://www.npmjs.com/package/grunt-remove-logging)
}
},
uglify: {
min: {
src : ['build/<%= pkg.name %>.dist.js'],
dest : 'build/<%= pkg.name %>.min.js',
},
options: {
// Add a banner with the package name and version
// (no date, otherwise a new build is different even if the code didn't change!)
banner: '/*! <%= pkg.name %> V<%= pkg.version %> */\n',
// Preserve comments that start with a bang (like the file header)
preserveComments: "some"
}
},
cssmin: {
min: {
src : [
'styles/ableplayer.css',
'styles/ableplayer-playlist.css',
'styles/ableplayer-search.css',
'styles/ableplayer-transcript.css'
],
dest : 'build/<%= pkg.name %>.min.css',
},
options: {
// Add a banner with the package name and version
// (no date, otherwise a new build is different even if the code didn't change!)
// (oddly, here we don't need a '\n' at the end!)
banner: '/*! <%= pkg.name %> V<%= pkg.version %> */',
}
},
jshint: {
files: ['Gruntfile.js', 'scripts/**/*.js'],
options: {
// options here to override JSHint defaults
globals: {
browser: true,
jquery: true,
devel: true,
}
}
},
clean: {
build: ['build'],
},

});

grunt.registerTask('default', ['concat', 'removelogging', 'uglify', 'cssmin']);
grunt.registerTask('test', ['jshint']);
};
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,34 @@ users can control the following:
- Highlight transcript as video plays
- Keyboard-enable transcript

Building the Able Player source
-------------------------------

The source JavaScript files for the ableplayer are in the */scripts* directory,
and are combined into several different files (in the */build* directory) using
[npm][] and [Grunt][]:

```sh
npm install
grunt
```

The npm and Grunt build process is defined by the *Gruntfile.js* and *package.json*
files. (Note that the **version number** is specified in *package.json*, and must be
updated when a new version is released).

Files created by the build process are put into the */build* directory:

- **build/ableplayer.js** -
the default build of *ableplayer.js*
- **build/ableplayer.dist.js** -
a build of *ableplayer.js* without console logging
- **build/ableplayer.min.js** -
a minified version of the *dist* file
- **build/ableplayer.min.css** -
a minified version of the *styles/ableplayer.css* file


[examples]: http://ableplayer.github.io/ableplayer/tests/
[jQuery]: http://jquery.com/
[Modernizr]: http://modernizr.com/
Expand All @@ -448,6 +475,7 @@ users can control the following:
[WebAIM’s 2014 Screen Reader User Survey]: http://webaim.org/projects/screenreadersurvey5/#browsers
[Configuring MIME Types in IIS 7]: http://technet.microsoft.com/en-us/library/17bda1f4-8a0d-440f-986a-5aaa9d40b74c.aspx
[How to add MIME Types with IIS7 Web.config]: http://blogs.iis.net/bills/archive/2008/03/25/how-to-add-mime-types-with-iis7-web-config.aspx

[npm]: https://www.npmjs.com/
[grunt]: http://gruntjs.com/


21 changes: 0 additions & 21 deletions compile.sh

This file was deleted.

18 changes: 18 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "ableplayer",
"version": "2.03.0",
"repository": {
"type": "git",
"url": "https://github.com/ableplayer/ableplayer.git"
},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-clean": "~0.6.0",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-cssmin": "~0.6.1",
"grunt-contrib-jshint": "^0.10.0",
"grunt-contrib-uglify": "~0.2.2",
"grunt-remove-logging": "~0.2.0"
}
}

0 comments on commit e8c5339

Please sign in to comment.