I'm trying to convert a old gulpjs file to es6 but i keep getting this error message in the concat
task:
Error: Recived a non-Vinyl object in dest()
My gulpfile.js
:
import gulp from 'gulp';
/*********** Jade and Pug templating ***********/
import jade from 'gulp-jade';
import pug from 'gulp-pug';
/*********** SASS and SCSS compiling ***********/
import sass from 'gulp-sass';
import autoprefixer from 'gulp-autoprefixer';
import cleanCss from 'gulp-clean-css';
/*********** JS concat and minify ***********/
import concat from 'gulp-concat';
import minify from 'gulp-minify';
/*********** Static server ***********/
import bs from 'browser-sync';
const dirs = {
pug_src: 'views',
sass_src: 'assets/scss',
js_src: 'assets/js',
dist: 'dist',
js_dist: 'dist/js/',
sass_dist: 'dist/css/'
};
const files = {
pug: `${dirs.pug_src}/*.pug`,
sass: `${dirs.sass_src}/*.sass`,
js: `${dirs.js_src}/*.js`,
html: `${dirs.dist}/*.html`
}
/*********** HTML ***********/
gulp.task('pug', () => {
return gulp.src(files.pug)
.pipe(pug({
pretty: false
}).on('error', (e) => {
console.log(e)
}))
.pipe(gulp.dest(dirs.dist));
});
/*********** Styles ***********/
gulp.task('sass', () => {
return gulp.src(files.sass)
.pipe(sass({
outputStyle: 'compressed'
})
.on('error', sass.logError))
.pipe(gulp.dest(dirs.sass_dist))
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(cleanCss({
compatibility: 'ie8'
}))
.pipe(bs.stream());
});
/*********** Concat JS files ***********/
gulp.task('concat', () => {
return gulp.src(files.js)
.pipe(concat('main.js'))
.pipe(minify({
src: 'main.js',
min: '.min.js'
}))
.pipe(gulp.dest(dirs.js_dist));
});
/*********** BrowserSync ***********/
gulp.task('serve', gulp.series('pug', 'sass', 'concat'), () => {
bs.init({
server: {
baseDir: dirs.dist
}
});
});
/*********** Watch ***********/
gulp.task('watch', () => {
gulp.watch(files.pug, gulp.series('pug'));
gulp.watch(files.sass, gulp.series('sass'));
gulp.watch(files.js, gulp.series('concat')).on('change', bs.reload);
gulp.watch(files.html).on('change', bs.reload);
});
/*********** Default ***********/
gulp.task('default', gulp.series('serve', 'watch'));
i have changed the gulp.dist()
from gulp.dest(dirs.js_dist)
to gulp.dest('dist/js/')
and still got the same error.
[16:30:20] Failed to load external module @babel/register
[16:30:20] Requiring external module babel-register
[16:30:38] Using gulpfile ~/Workspace/Projects/AHTM-source/gulpfile.babel.js
[16:30:38] Starting 'default'...
[16:30:38] Starting 'serve'...
[16:30:38] Starting 'pug'...
[16:30:38] Finished 'pug' after 415 ms
[16:30:38] Starting 'sass'...
[16:30:39] Finished 'sass' after 369 ms
[16:30:39] Starting 'concat'...
[16:30:39] 'concat' errored after 69 ms
[16:30:39] Error: Received a non-Vinyl object in `dest()`
at DestroyableTransform.normalize [as _transform] (/home/cdetecnologias/Workspace/Projects/AHTM-source/node_modules/vinyl-fs/lib/dest/prepare.js:16:17)
at DestroyableTransform.Transform._read (/home/cdetecnologias/Workspace/Projects/AHTM-source/node_modules/readable-stream/lib/_stream_transform.js:184:10)
at DestroyableTransform.Transform._write (/home/cdetecnologias/Workspace/Projects/AHTM-source/node_modules/readable-stream/lib/_stream_transform.js:172:83)
at doWrite (/home/cdetecnologias/Workspace/Projects/AHTM-source/node_modules/readable-stream/lib/_stream_writable.js:428:64)
at writeOrBuffer (/home/cdetecnologias/Workspace/Projects/AHTM-source/node_modules/readable-stream/lib/_stream_writable.js:417:5)
at DestroyableTransform.Writable.write (/home/cdetecnologias/Workspace/Projects/AHTM-source/node_modules/readable-stream/lib/_stream_writable.js:334:11)
at Pumpify.Duplexify._write (/home/cdetecnologias/Workspace/Projects/AHTM-source/node_modules/duplexify/index.js:208:22)
at doWrite (/home/cdetecnologias/Workspace/Projects/AHTM-source/node_modules/readable-stream/lib/_stream_writable.js:428:64)
at writeOrBuffer (/home/cdetecnologias/Workspace/Projects/AHTM-source/node_modules/readable-stream/lib/_stream_writable.js:417:5)
at Pumpify.Writable.write (/home/cdetecnologias/Workspace/Projects/AHTM-source/node_modules/readable-stream/lib/_stream_writable.js:334:11)
[16:30:39] 'serve' errored after 856 ms
[16:30:39] 'default' errored after 859 ms