fathom/gulpfile.js

77 lines
2.2 KiB
JavaScript
Raw Normal View History

'use strict';
2016-12-08 11:43:13 +00:00
const browserify = require('browserify')
const gulp = require('gulp')
const source = require('vinyl-source-stream')
const buffer = require('vinyl-buffer')
const uglify = require('gulp-uglify')
const babel = require('gulp-babel');
const cachebust = require('gulp-cache-bust');
const concat = require('gulp-concat');
const gulpif = require('gulp-if')
2016-12-10 14:58:54 +00:00
const debug = process.env.NODE_ENV !== 'production';
2018-09-14 08:25:31 +00:00
gulp.task('app-js', function () {
return browserify({
2018-09-14 08:25:31 +00:00
entries: './assets/src/js/script.js',
debug: debug,
ignoreMissing: true,
})
.transform("babelify", {
2018-09-14 08:25:31 +00:00
presets: ["@babel/preset-env"],
plugins: [
2018-09-14 08:25:31 +00:00
["@babel/plugin-proposal-decorators", { "legacy": true }],
["@babel/plugin-transform-react-jsx", { "pragma":"h" } ]
]
2018-09-14 08:25:31 +00:00
})
.bundle()
2018-09-14 08:25:31 +00:00
.pipe(source('script.js'))
.pipe(buffer())
.pipe(gulpif(!debug, uglify()))
.pipe(gulp.dest(`./assets/build/js`))
2018-09-14 08:25:31 +00:00
});
2018-09-14 08:25:31 +00:00
gulp.task('tracker-js', function () {
return gulp.src('./assets/src/js/tracker.js')
.pipe(babel({
presets: ["@babel/preset-env"],
}))
.pipe(gulpif(!debug, uglify()))
2018-09-14 08:25:31 +00:00
.pipe(gulp.dest('./assets/build/js'));
2016-12-08 11:43:13 +00:00
});
2018-09-14 08:41:44 +00:00
gulp.task('fonts', function() {
return gulp.src('./assets/src/fonts/**/*')
.pipe(gulp.dest(`./assets/build/fonts`))
});
2016-11-26 15:17:52 +00:00
gulp.task('img', function() {
return gulp.src('./assets/src/img/**/*')
.pipe(gulp.dest(`./assets/build/img`))
2016-11-26 15:17:52 +00:00
});
gulp.task('html', function() {
return gulp.src('./assets/src/**/*.html')
.pipe(cachebust({
type: 'timestamp'
}))
.pipe(gulp.dest(`./assets/build/`))
});
2016-11-26 15:17:52 +00:00
gulp.task('css', function () {
return gulp.src('./assets/src/css/*.css')
.pipe(concat('styles.css'))
.pipe(gulp.dest(`./assets/build/css`))
});
gulp.task('default', gulp.series('app-js', 'tracker-js', 'css', 'html', 'img', 'fonts' ) );
2018-10-30 15:14:36 +00:00
gulp.task('watch', gulp.series('default', function() {
2018-10-30 15:26:35 +00:00
gulp.watch(['./assets/src/js/**/*.js'], gulp.parallel('app-js', 'tracker-js') );
gulp.watch(['./assets/src/css/**/*.css'], gulp.parallel( 'css') );
2018-10-30 15:26:35 +00:00
gulp.watch(['./assets/src/**/*.html'], gulp.parallel( 'html') );
gulp.watch(['./assets/src/img/**/*'], gulp.parallel( 'img') );
gulp.watch(['./assets/src/fonts/**/*'], gulp.parallel( 'fonts') );
2018-10-30 15:14:36 +00:00
}));