hugvey/www/gulpfile.js

83 lines
2.2 KiB
JavaScript
Raw Normal View History

2019-01-23 14:26:44 +00:00
var gulp = require('gulp');
var sass = require('gulp-sass');
//var babel = require('gulp-babel');
//var concat = require('gulp-concat');
//var rename = require('gulp-rename');
//var uglify = require('gulp-uglify');
//var rollup = require('rollup-stream');
//var sourcemaps = require('gulp-sourcemaps');
var browserSync = require('browser-sync');
var through = require('through2')
// todo: rollup for d3 & possibly jsonld
var paths = {
"styles": {
"src": "./scss/*.scss",
"dest": "./css/"
}
};
gulp.task('styles', function() {
gulp.src(paths.styles.src, { sourcemaps: true })
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest(paths.styles.dest))
.pipe(browserSync.reload({ stream: true }));
});
/*gulp.task('scripts', function() {
return gulp.src(paths.scripts.src)
.pipe(sourcemaps.init())
.pipe(babel({
ignore: [
'./src/d3.v5.js',
'./src/vue.js',
]
}))
.pipe(concat('portfolio.js'))
.pipe(gulp.dest(paths.scripts.dest)) // save .js
.pipe(uglify())
.pipe(rename({ extname: '.min.js' }))
// .pipe(sourcemaps.write('maps'))
.pipe(gulp.dest(paths.scripts.d3destDir)) // save .min.js
});
gulp.task('d3', function() {
return rollup( 'rollup.config.js' )
.pipe(source('d3.bundle.js'))
.pipe(gulp.dest(paths.scripts.d3destDir)) // save .js
.pipe(buffer())
.pipe(uglify())
.pipe(rename({ extname: '.min.js' }))
.pipe(sourcemaps.write('maps'))
.pipe(gulp.dest(paths.scripts.d3destDir)) // save .min.js
});
*/
var watchStylesAndScripts = function() {
gulp.watch(paths.styles.src,['styles']);
// gulp.watch(paths.scripts.src,['scripts', browserSync.reload]);
// gulp.watch(paths.scripts.d3src,['d3', browserSync.reload]);
}
gulp.task('watch', watchStylesAndScripts);
// watch files for changes and reload
gulp.task('serve', function() {
browserSync.init({
proxy: {
target: "localhost:8888",
ws: true
},
port: 3000
});
gulp.watch(['index.html', 'js/hugvey_console.js'], browserSync.reload);
watchStylesAndScripts();
});
gulp.task('default', ['serve']);