2016-01-23 12:26:56 -05:00
|
|
|
/*
|
|
|
|
* Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
|
|
|
|
* http://paperjs.org/
|
|
|
|
*
|
2020-05-23 16:24:42 -04:00
|
|
|
* Copyright (c) 2011 - 2020, Jürg Lehni & Jonathan Puckey
|
|
|
|
* http://juerglehni.com/ & https://puckey.studio/
|
2016-01-23 12:26:56 -05:00
|
|
|
*
|
|
|
|
* Distributed under the MIT license. See LICENSE file for details.
|
|
|
|
*
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
var gulp = require('gulp'),
|
|
|
|
prepro = require('gulp-prepro'),
|
|
|
|
rename = require('gulp-rename'),
|
|
|
|
uncomment = require('gulp-uncomment'),
|
|
|
|
whitespace = require('gulp-whitespace'),
|
2016-01-25 05:06:45 -05:00
|
|
|
del = require('del'),
|
2016-07-09 14:56:58 -04:00
|
|
|
options = require('../utils/options.js');
|
2016-01-23 12:26:56 -05:00
|
|
|
|
|
|
|
// Options to be used in Prepro.js preprocessing through the global __options
|
|
|
|
// object, merged in with the options required above.
|
|
|
|
var buildOptions = {
|
|
|
|
full: { paperScript: true },
|
2016-01-26 14:02:23 -05:00
|
|
|
core: { paperScript: false }
|
2016-01-23 12:26:56 -05:00
|
|
|
};
|
|
|
|
|
2016-01-25 05:26:08 -05:00
|
|
|
var buildNames = Object.keys(buildOptions);
|
|
|
|
|
2016-01-23 12:26:56 -05:00
|
|
|
gulp.task('build',
|
2016-01-25 05:26:08 -05:00
|
|
|
buildNames.map(function(name) {
|
2016-01-23 12:26:56 -05:00
|
|
|
return 'build:' + name;
|
2016-01-26 14:02:23 -05:00
|
|
|
}).concat(['build:copy'])
|
2016-01-23 12:26:56 -05:00
|
|
|
);
|
|
|
|
|
2016-01-26 14:02:23 -05:00
|
|
|
gulp.task('build:copy', function() {
|
|
|
|
gulp.src(['src/node/*.js']).pipe(gulp.dest('dist/node'));
|
|
|
|
});
|
|
|
|
|
2016-01-25 05:26:08 -05:00
|
|
|
buildNames.forEach(function(name) {
|
|
|
|
gulp.task('build:' + name, ['clean:build:' + name, 'minify:acorn'], function() {
|
2016-01-23 12:26:56 -05:00
|
|
|
return gulp.src('src/paper.js')
|
|
|
|
.pipe(prepro({
|
|
|
|
// Evaluate constants.js inside the precompilation scope before
|
|
|
|
// the actual precompilation, so all the constants substitution
|
|
|
|
// statements in the code can work (look for: /*#=*/):
|
|
|
|
evaluate: ['src/constants.js'],
|
|
|
|
setup: function() {
|
|
|
|
// Return objects to be defined in the preprocess-scope.
|
2016-07-12 13:11:09 -04:00
|
|
|
// Note that this would be merged in with already existing
|
2016-01-23 12:26:56 -05:00
|
|
|
// objects.
|
|
|
|
return {
|
2016-07-09 17:36:11 -04:00
|
|
|
__options: Object.assign({}, options, buildOptions[name])
|
2016-01-23 12:26:56 -05:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}))
|
|
|
|
.pipe(uncomment({
|
|
|
|
mergeEmptyLines: true
|
|
|
|
}))
|
|
|
|
.pipe(whitespace({
|
|
|
|
spacesToTabs: 4,
|
|
|
|
removeTrailing: true
|
|
|
|
}))
|
|
|
|
.pipe(rename({
|
2016-01-25 05:26:08 -05:00
|
|
|
suffix: '-' + name
|
2016-01-23 12:26:56 -05:00
|
|
|
}))
|
|
|
|
.pipe(gulp.dest('dist'));
|
|
|
|
});
|
2016-01-25 05:06:45 -05:00
|
|
|
|
2016-01-25 05:26:08 -05:00
|
|
|
gulp.task('clean:build:' + name, function() {
|
|
|
|
return del([
|
2016-01-29 20:56:05 -05:00
|
|
|
'dist/paper-' + name + '*.js'
|
2016-01-25 05:26:08 -05:00
|
|
|
]);
|
|
|
|
});
|
2016-01-23 12:26:56 -05:00
|
|
|
});
|