2018-07-04 19:48:45 +02:00
|
|
|
import gulp from 'gulp';
|
|
|
|
import pump from 'pump';
|
|
|
|
import del from 'del';
|
|
|
|
import copy from 'gulp-copy';
|
|
|
|
import rename from 'gulp-rename';
|
|
|
|
import inject from 'gulp-inject-string';
|
|
|
|
import copydeps from 'gulp-npm-copy-deps';
|
|
|
|
import file from 'gulp-file';
|
|
|
|
import editjson from 'gulp-json-editor';
|
|
|
|
|
|
|
|
import corepkg from './core/package';
|
|
|
|
import clientpkg from './client/package';
|
|
|
|
|
|
|
|
gulp.task('release-package', function () {
|
|
|
|
return pump([
|
|
|
|
gulp.src('package.json'),
|
|
|
|
editjson(function (mainpkg) {
|
|
|
|
delete mainpkg.main;
|
|
|
|
delete mainpkg.devDependencies;
|
|
|
|
delete mainpkg.scripts;
|
|
|
|
return mainpkg;
|
|
|
|
}),
|
|
|
|
gulp.dest('release')
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('client', function () {
|
|
|
|
return pump([
|
|
|
|
gulp.src('client/dist/*.client-release.js'),
|
|
|
|
rename(`client.${clientpkg.version}.js`),
|
|
|
|
gulp.dest('release')
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('core', function () {
|
|
|
|
return pump([
|
|
|
|
gulp.src('core/dist/main.js'),
|
|
|
|
inject.after("'use strict';\n", 'const PRODUCTION = true;\n'),
|
|
|
|
rename(`core.${corepkg.version}.js`),
|
|
|
|
gulp.dest('release')
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('sparkplug', function () {
|
|
|
|
return pump([
|
|
|
|
gulp.src('core/dist/sparkplug.js'),
|
|
|
|
gulp.dest('release')
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('core-modules', function () {
|
|
|
|
return pump([
|
|
|
|
gulp.src('core/dist/modules/**/*'),
|
|
|
|
copy('release', { prefix: 2 })
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('index', function () {
|
|
|
|
return pump([
|
|
|
|
file('index.js', `module.exports = require('./core.${corepkg.version}.js');`, {src: true}),
|
|
|
|
gulp.dest('release')
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('css-editor', function () {
|
|
|
|
return pump([
|
|
|
|
gulp.src('csseditor/dist/csseditor-release.js'),
|
|
|
|
rename('csseditor.js'),
|
|
|
|
gulp.dest('release/csseditor')
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('dependencies', function () {
|
|
|
|
return copydeps('.', 'release');
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('node-sass-bindings', function () {
|
|
|
|
return pump([
|
|
|
|
gulp.src('other/node_sass_bindings/**/*'),
|
|
|
|
copy('release/node_modules/node-sass/vendor', { prefix: 2 })
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
|
2018-08-10 16:43:28 +02:00
|
|
|
gulp.task('build-release', gulp.parallel('release-package', 'client', 'core', 'sparkplug', 'core-modules', 'index', 'css-editor', gulp.series('dependencies', 'node-sass-bindings')));
|
|
|
|
|
2018-07-04 19:48:45 +02:00
|
|
|
gulp.task('release', gulp.series(function () {
|
|
|
|
return del(['release/**/*']);
|
2018-08-10 16:43:28 +02:00
|
|
|
}, 'build-release'));
|