Reputation: 3
how to fix my problem? Here is my gulpfile.js
const gulp = require('gulp');
const webp = require('gulp-webp');
const browserSync = require('browser-sync');
const origin = 'app';
const destination = 'app';
gulp.task('webp', () =>
gulp
.src(`${origin}/img/**`)
.pipe(webp())
.pipe(gulp.dest(`${destination}/img`))
);
gulp.task('live', function () {
gulp.watch('**/*.css').on('change', function () {
browserSync.reload();
});
});
And here is my package.json
{
"name": "gulp-browsersync",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"watch": "node-sass --watch app/scss -o app/css"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"browser-sync": "^2.26.10",
"gulp": "^4.0.2",
"gulp-webp": "^4.0.1",
"node-sass": "^4.14.1"
},
"dependencies": {}
}
And this is my terminal log
[13:39:25] Using gulpfile ~\Desktop\gulp-browsersync-main\gulpfile.js [13:39:25] Task never defined: default [13:39:25] To list available tasks, try running: gulp --tasks
Upvotes: 0
Views: 6906
Reputation: 762
You need to exports
a function as default
from your gulpfile.js
check gulp-doc and creating-tasks
gulp need a function to start tasks and you must exports.default
your main task function.
if you have multiple tasks you need to use series
or parallel
.
code:
const gulp = require('gulp');
const webp = require('gulp-webp');
const browserSync = require('browser-sync');
const origin = 'app';
const destination = 'app';
function defaultTask(cb) {
gulp.task('webp', () =>
gulp
.src(`${origin}/img/**`)
.pipe(webp())
.pipe(gulp.dest(`${destination}/img`))
);
gulp.task('live', function () {
gulp.watch('**/*.css').on('change', function () {
browserSync.reload();
});
});
cb();
}
exports.default = defaultTask
Upvotes: 1