This repository has been archived by the owner on Mar 4, 2021. It is now read-only.
forked from chartjs/Chart.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add build sequence + dev dependencies
- Loading branch information
Showing
2 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
var gulp = require('gulp'), | ||
concat = require('gulp-concat'), | ||
uglify = require('gulp-uglify'), | ||
util = require('gulp-util'), | ||
jshint = require('gulp-jshint'), | ||
size = require('gulp-size'), | ||
connect = require('gulp-connect'), | ||
exec = require('child_process').exec; | ||
|
||
var srcDir = './src/'; | ||
/* | ||
* Usage : gulp build --types=Bar,Line,Doughnut | ||
* Output: - A built Chart.js file with Core and types Bar, Line and Doughnut concatenated together | ||
* - A minified version of this code, in Chart.min.js | ||
*/ | ||
|
||
gulp.task('build', function(){ | ||
|
||
// Default to all of the chart types, with Chart.Core first | ||
var srcFiles = [FileName('Core')], | ||
isCustom = !!(util.env.types), | ||
outputDir = (isCustom) ? 'custom' : '.'; | ||
if (isCustom){ | ||
util.env.types.split(',').forEach(function(type){ return srcFiles.push(FileName(type))}); | ||
} | ||
else{ | ||
// Seems gulp-concat remove duplicates - nice! | ||
// So we can use this to sort out dependency order - aka include Core first! | ||
srcFiles.push(srcDir+'*'); | ||
} | ||
return gulp.src(srcFiles) | ||
.pipe(concat('Chart.js')) | ||
.pipe(gulp.dest(outputDir)) | ||
.pipe(uglify({preserveComments:'some'})) | ||
.pipe(concat('Chart.min.js')) | ||
.pipe(gulp.dest(outputDir)); | ||
|
||
function FileName(moduleName){ | ||
return srcDir+'Chart.'+moduleName+'.js'; | ||
}; | ||
}); | ||
|
||
gulp.task('jshint', function(){ | ||
return gulp.src(srcDir + '*.js') | ||
.pipe(jshint()) | ||
.pipe(jshint.reporter('default')); | ||
}); | ||
|
||
gulp.task('library-size', function(){ | ||
return gulp.src('Chart.min.js') | ||
.pipe(size({ | ||
gzip: true | ||
})); | ||
}); | ||
|
||
gulp.task('module-sizes', function(){ | ||
return gulp.src(srcDir + '*.js') | ||
.pipe(uglify({preserveComments:'some'})) | ||
.pipe(size({ | ||
showFiles: true, | ||
gzip: true | ||
})) | ||
}); | ||
|
||
gulp.task('watch', function(){ | ||
gulp.watch('./src/*', ['build']); | ||
}); | ||
|
||
gulp.task('test', ['jshint']); | ||
|
||
gulp.task('size', ['library-size', 'module-sizes']); | ||
|
||
gulp.task('default', ['build', 'watch']); | ||
|
||
gulp.task('server', function(){ | ||
connect.server({ | ||
port: 8000, | ||
}); | ||
}); | ||
|
||
// Convenience task for opening the project straight from the command line | ||
gulp.task('_open', function(){ | ||
exec('open http://localhost:8000'); | ||
exec('subl .'); | ||
}); | ||
|
||
gulp.task('dev', ['server', 'default']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "Chart.js", | ||
"homepage": "http://www.chartjs.org", | ||
"description": "Simple HTML5 charts using the canvas element.", | ||
"private": true, | ||
"version": "1.0.0-beta", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/nnnick/Chart.js.git" | ||
}, | ||
"dependences": {}, | ||
"devDependencies": { | ||
"gulp": "3.5.x", | ||
"gulp-concat": "~2.1.x", | ||
"gulp-uglify": "~0.2.x", | ||
"gulp-util": "~2.2.x", | ||
"gulp-jshint": "~1.5.1", | ||
"gulp-size": "~0.4.0", | ||
"gulp-connect": "~2.0.5" | ||
} | ||
} |