2019-05-29 02:19:07 +03:00
|
|
|
var gulp = require('gulp');
|
|
|
|
var cssimport = require('gulp-cssimport');
|
|
|
|
var rollup = require('gulp-better-rollup');
|
2019-07-12 03:19:56 +03:00
|
|
|
var cssnano = require('cssnano');
|
|
|
|
var autoprefixer = require('autoprefixer');
|
|
|
|
var postcss = require('gulp-postcss')
|
2019-05-29 02:19:07 +03:00
|
|
|
var sucrase = require('@sucrase/gulp-plugin');
|
|
|
|
var minify = require('gulp-minify');
|
2019-07-12 03:19:56 +03:00
|
|
|
var exec = require('child_process').exec;
|
2019-05-29 02:19:07 +03:00
|
|
|
|
|
|
|
var resolve = require('rollup-plugin-node-resolve');
|
|
|
|
var commonjs = require('rollup-plugin-commonjs');
|
|
|
|
var replace = require('rollup-plugin-replace');
|
|
|
|
var json = require('rollup-plugin-json');
|
2019-07-12 03:19:56 +03:00
|
|
|
var builtins = require('@joseph184/rollup-plugin-node-builtins');
|
2019-05-29 02:19:07 +03:00
|
|
|
var rootImport = require('rollup-plugin-root-import');
|
|
|
|
var globals = require('rollup-plugin-node-globals');
|
|
|
|
|
|
|
|
/***
|
|
|
|
Main config options
|
|
|
|
***/
|
|
|
|
|
2019-07-23 23:08:04 +03:00
|
|
|
var urbitrc = require('../urbitrc');
|
2019-05-29 02:19:07 +03:00
|
|
|
|
|
|
|
/***
|
|
|
|
End main config options
|
|
|
|
***/
|
|
|
|
|
2019-07-12 03:19:56 +03:00
|
|
|
gulp.task('jsx-transform', function (cb) {
|
2019-05-29 02:19:07 +03:00
|
|
|
return gulp.src('src/**/*.js')
|
|
|
|
.pipe(sucrase({
|
|
|
|
transforms: ['jsx']
|
|
|
|
}))
|
|
|
|
.pipe(gulp.dest('dist'));
|
|
|
|
});
|
|
|
|
|
2019-07-12 03:19:56 +03:00
|
|
|
gulp.task('tile-jsx-transform', function (cb) {
|
2019-05-29 02:19:07 +03:00
|
|
|
return gulp.src('tile/**/*.js')
|
|
|
|
.pipe(sucrase({
|
|
|
|
transforms: ['jsx']
|
|
|
|
}))
|
|
|
|
.pipe(gulp.dest('dist'));
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2019-07-12 03:19:56 +03:00
|
|
|
gulp.task('js-imports', function (cb) {
|
2019-05-29 02:19:07 +03:00
|
|
|
return gulp.src('dist/index.js')
|
|
|
|
.pipe(rollup({
|
|
|
|
plugins: [
|
|
|
|
commonjs({
|
|
|
|
namedExports: {
|
2019-07-12 03:19:56 +03:00
|
|
|
'node_modules/react/index.js': ['Component'],
|
|
|
|
'node_modules/react-is/index.js': ['isValidElementType'],
|
2019-05-29 02:19:07 +03:00
|
|
|
}
|
|
|
|
}),
|
|
|
|
rootImport({
|
|
|
|
root: `${__dirname}/dist/js`,
|
|
|
|
useEntry: 'prepend',
|
|
|
|
extensions: '.js'
|
|
|
|
}),
|
|
|
|
json(),
|
|
|
|
globals(),
|
|
|
|
builtins(),
|
|
|
|
resolve()
|
|
|
|
]
|
|
|
|
}, 'umd'))
|
2019-07-12 03:19:56 +03:00
|
|
|
.on('error', function (e) {
|
2019-05-29 02:19:07 +03:00
|
|
|
console.log(e);
|
|
|
|
cb();
|
|
|
|
})
|
2019-07-23 23:08:04 +03:00
|
|
|
.pipe(gulp.dest('../../arvo/app/clock/js/'))
|
2019-05-29 02:19:07 +03:00
|
|
|
.on('end', cb);
|
|
|
|
});
|
|
|
|
|
2019-07-12 03:19:56 +03:00
|
|
|
gulp.task('tile-js-imports', function (cb) {
|
2019-05-29 02:19:07 +03:00
|
|
|
return gulp.src('dist/tile.js')
|
|
|
|
.pipe(rollup({
|
|
|
|
plugins: [
|
|
|
|
commonjs({
|
|
|
|
namedExports: {
|
2019-07-12 03:19:56 +03:00
|
|
|
'node_modules/react/index.js': ['Component'],
|
2019-05-29 02:19:07 +03:00
|
|
|
}
|
|
|
|
}),
|
|
|
|
rootImport({
|
|
|
|
root: `${__dirname}/dist/js`,
|
|
|
|
useEntry: 'prepend',
|
|
|
|
extensions: '.js'
|
|
|
|
}),
|
|
|
|
json(),
|
|
|
|
globals(),
|
|
|
|
builtins(),
|
|
|
|
resolve()
|
|
|
|
]
|
|
|
|
}, 'umd'))
|
2019-07-12 03:19:56 +03:00
|
|
|
.on('error', function (e) {
|
2019-05-29 02:19:07 +03:00
|
|
|
console.log(e);
|
|
|
|
cb();
|
|
|
|
})
|
2019-07-23 23:08:04 +03:00
|
|
|
.pipe(gulp.dest('../../arvo/app/clock/js/'))
|
2019-05-29 02:19:07 +03:00
|
|
|
.on('end', cb);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('js-minify', function () {
|
2019-07-23 23:08:04 +03:00
|
|
|
return gulp.src('../../arvo/app/clock/js/index.js')
|
2019-05-29 02:19:07 +03:00
|
|
|
.pipe(minify())
|
2019-07-23 23:08:04 +03:00
|
|
|
.pipe(gulp.dest('../../arvo/app/clock/js/'));
|
2019-05-29 02:19:07 +03:00
|
|
|
});
|
|
|
|
|
2019-06-28 23:23:19 +03:00
|
|
|
gulp.task('tile-js-minify', function () {
|
2019-07-23 23:08:04 +03:00
|
|
|
return gulp.src('../../arvo/app/clock/js/tile.js')
|
2019-06-28 23:23:19 +03:00
|
|
|
.pipe(minify())
|
2019-07-23 23:08:04 +03:00
|
|
|
.pipe(gulp.dest('../../arvo/app/clock/js/'));
|
2019-06-28 23:23:19 +03:00
|
|
|
});
|
|
|
|
|
2019-05-29 02:19:07 +03:00
|
|
|
gulp.task('urbit-copy', function () {
|
2019-07-23 23:08:04 +03:00
|
|
|
let ret = gulp.src('../../arvo/**/*');
|
2019-05-29 02:19:07 +03:00
|
|
|
|
2019-07-12 03:19:56 +03:00
|
|
|
urbitrc.URBIT_PIERS.forEach(function (pier) {
|
2019-05-29 02:19:07 +03:00
|
|
|
ret = ret.pipe(gulp.dest(pier));
|
|
|
|
});
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('tile-js-bundle-dev', gulp.series('tile-jsx-transform', 'tile-js-imports'));
|
2019-06-28 23:23:19 +03:00
|
|
|
gulp.task('tile-js-bundle-prod',
|
|
|
|
gulp.series('tile-jsx-transform', 'tile-js-imports', 'tile-js-minify'));
|
|
|
|
|
|
|
|
gulp.task('bundle-prod', gulp.series('tile-js-bundle-prod', 'urbit-copy'));
|
2019-05-29 02:19:07 +03:00
|
|
|
|
|
|
|
gulp.task('default', gulp.series('tile-js-bundle-dev', 'urbit-copy'));
|
2019-07-12 03:19:56 +03:00
|
|
|
gulp.task('watch', gulp.series('default', function () {
|
2019-05-29 02:19:07 +03:00
|
|
|
gulp.watch('tile/**/*.js', gulp.parallel('tile-js-bundle-dev'));
|
2019-07-23 23:08:04 +03:00
|
|
|
gulp.watch('../../arvo/**/*', gulp.parallel('urbit-copy'));
|
|
|
|
}));
|