Browse Source

Some minor improvements to the build script

v3_develop
jos 10 years ago
parent
commit
434a67a5fb
2 changed files with 22 additions and 11 deletions
  1. +19
    -9
      gulpfile.js
  2. +3
    -2
      package.json

+ 19
- 9
gulpfile.js View File

@ -8,6 +8,7 @@ var webpack = require('webpack');
var uglify = require('uglify-js');
var rimraf = require('rimraf');
var merge = require('merge-stream');
var argv = require('yargs').argv;
var ENTRY = './index.js';
var HEADER = './lib/header.js';
@ -58,9 +59,9 @@ var uglifyConfig = {
// create a single instance of the compiler to allow caching
var compiler = webpack(webpackConfig);
// clean the dist directory
// clean the dist/img directory
gulp.task('clean', function (cb) {
rimraf(DIST, cb);
rimraf(DIST + '/img', cb);
});
gulp.task('bundle-js', ['clean'], function (cb) {
@ -124,15 +125,24 @@ gulp.task('minify', ['bundle-js'], function (cb) {
gulp.task('bundle', ['bundle-js', 'bundle-css', 'copy-img']);
// The watch task (to automatically rebuild when the source code changes)
gulp.task('watch', ['bundle', 'minify'], function () {
gulp.watch(['index.js', 'lib/**/*'], ['bundle', 'minify']);
});
// read command line arguments --bundle and --minify
var bundle = 'bundle' in argv;
var minify = 'minify' in argv;
var watchTasks = [];
if (bundle || minify) {
// do bundling and/or minifying only when specified on the command line
watchTasks = [];
if (bundle) watchTasks.push('bundle');
if (minify) watchTasks.push('minify');
}
else {
// by default, do both bundling and minifying
watchTasks = ['bundle', 'minify'];
}
// The watch task (to automatically rebuild when the source code changes)
// this watch only rebuilds vis.js, not vis.min.js
gulp.task('watch-dev', ['bundle'], function () {
gulp.watch(['index.js', 'lib/**/*'], ['bundle']);
gulp.task('watch', watchTasks, function () {
gulp.watch(['index.js', 'lib/**/*'], watchTasks);
});
// The default task (called when you run `gulp`)

+ 3
- 2
package.json View File

@ -25,7 +25,7 @@
"test": "mocha",
"build": "gulp",
"watch": "gulp watch",
"watch-dev": "gulp watch-dev"
"watch-dev": "gulp watch --bundle"
},
"dependencies": {
"emitter-component": "^1.1.1",
@ -45,6 +45,7 @@
"rimraf": "^2.2.8",
"uglify-js": "^2.4.14",
"webpack": "^1.3.1-beta7",
"wrench": "latest"
"wrench": "latest",
"yargs": "^1.2.6"
}
}

Loading…
Cancel
Save