require to import

exports are not working
This commit is contained in:
Stephan Hagedorn 2022-08-11 08:41:39 +02:00
parent f7a5481fd2
commit da075e5beb
7 changed files with 69 additions and 72 deletions

View file

@ -1,4 +1,4 @@
const plumber = require('gulp-plumber');
import plumber from 'gulp-plumber';
// const notify = require('gulp-notify');
// function catchErrors(errTitle) {
@ -11,7 +11,7 @@ const plumber = require('gulp-plumber');
// });
// }
function catchErrors() {
export function catchErrors() {
return plumber({
errorHandler: function (err) {
// Logs error in console
@ -20,6 +20,5 @@ function catchErrors() {
this.emit('end');
}
});
}
module.exports = catchErrors;
}

View file

@ -1,9 +0,0 @@
const config = require('../config');
const del = require('del');
// Clean output folders
function clean() {
return del([config.dev + '**', config.rep + '**', config.dpl + '**']);
}
module.exports = clean;

8
gulp/tasks/clean.mjs Normal file
View file

@ -0,0 +1,8 @@
import config from '../config.js';
import { deleteAsync } from 'del';
// Clean output folders
export function clean() {
return deleteAsync([config.dev + '**', config.rep + '**', config.dpl + '**']);
}

View file

@ -1,16 +1,17 @@
const config = require('../config');
import config from '../config.js';
// const browserSync = require('browser-sync'), server = browserSync.create();
const server = require('browser-sync').create();
import browserSync from 'browser-sync'
const server = browserSync.create();
// Automagically reload browsers
function reload(done) {
export function reload(done) {
server.reload;
done();
}
// Serve files to the browser
function serve(done) {
export function serve(done) {
server.init({
index: config.index,
open: false,
@ -19,8 +20,3 @@ function serve(done) {
done();
}
module.exports = {
serve: serve,
reload: reload
};

View file

@ -1,13 +0,0 @@
const { src } = require('gulp');
const config = require('../config');
const plumber = require('../modules/plumber');
const htmlValidator = require('gulp-w3c-html-validator');
function validate() {
return src(config.dev + '**/*.html')
.pipe(plumber())
.pipe(htmlValidator())
.pipe(htmlValidator.reporter());
}
module.exports = validate;

14
gulp/tasks/validate.mjs Normal file
View file

@ -0,0 +1,14 @@
import gulp from 'gulp';
const { src } = gulp;
import config from '../config.js';
import plumber from '../modules/plumber.mjs';
import htmlValidator from 'gulp-w3c-html-validator';
function validate() {
return src(config.dev + '**/*.html')
.pipe(plumber())
.pipe(htmlValidator())
.pipe(htmlValidator.reporter());
}
module.exports = validate;