[bugfix]: Removed eslint.FailOnError()
Gulp watch would exit with 1 in gulp watch. The command had to to be rerun to start gulp again.
This commit is contained in:
parent
483582842a
commit
3f93c9f1dc
53
gulpfile.js
53
gulpfile.js
@ -11,28 +11,30 @@ const eslint = require("gulp-eslint");
|
||||
const babelify = require("babelify");
|
||||
const htmlmin = require("gulp-html-minifier-terser");
|
||||
const htmlvalidator = require("gulp-html");
|
||||
const imagemin = require('gulp-imagemin');
|
||||
const gulpif = require('gulp-if');
|
||||
const clean = require('gulp-dest-clean');
|
||||
|
||||
const html = () => {
|
||||
return gulp.src("src/index.html")
|
||||
return gulp
|
||||
.src("src/index.html")
|
||||
.pipe(htmlvalidator())
|
||||
.pipe(htmlmin({
|
||||
.pipe(
|
||||
htmlmin({
|
||||
removeComments: true,
|
||||
collapseWhitespace: true,
|
||||
collapseBooleanAttributes: true,
|
||||
collapseInlineTagWhitespace: true,
|
||||
removeRedundantAttributes: true,
|
||||
minifyCSS: true
|
||||
}))
|
||||
minifyCSS: true,
|
||||
}),
|
||||
)
|
||||
.pipe(gulp.dest("dist"));
|
||||
};
|
||||
|
||||
const js = () => {
|
||||
gulp.src(["src/**/*.ts", "!node_modules/**"])
|
||||
gulp
|
||||
.src(["src/**/*.ts", "!node_modules/**"])
|
||||
.pipe(eslint({ quiet: true }))
|
||||
.pipe(eslint.results(results => {
|
||||
.pipe(
|
||||
eslint.results(results => {
|
||||
// Called once for all ESLint results.
|
||||
console.log("ESLint results:\n");
|
||||
console.log(`Total Errors: ${results.errorCount}`);
|
||||
@ -40,18 +42,26 @@ const js = () => {
|
||||
results.forEach(file => {
|
||||
output += file.filePath + "\n";
|
||||
file.messages.forEach(message => {
|
||||
output += " - " + message.message + " at " + message.line + ":" + message.column + "\n";
|
||||
output +=
|
||||
" - " +
|
||||
message.message +
|
||||
" at " +
|
||||
message.line +
|
||||
":" +
|
||||
message.column +
|
||||
"\n";
|
||||
});
|
||||
output += "\n";
|
||||
});
|
||||
console.error(output);
|
||||
}))
|
||||
.pipe(eslint.failAfterError());
|
||||
}),
|
||||
);
|
||||
|
||||
return browserify("src/index.ts")
|
||||
.plugin(tsify, { noImplicitAny: true, target: "es6" })
|
||||
.transform(babelify, { extensions: [".tsx", ".ts"] })
|
||||
.bundle().on("error", (e) => console.error(e))
|
||||
.bundle()
|
||||
.on("error", e => console.error(e))
|
||||
.pipe(source("output.js"))
|
||||
.pipe(gulp.dest("dist"))
|
||||
.pipe(buffer())
|
||||
@ -63,24 +73,15 @@ const js = () => {
|
||||
};
|
||||
|
||||
const res = () => {
|
||||
return gulp.src("src/res/*")
|
||||
.pipe(clean("dist/res"))
|
||||
.pipe(gulpif(
|
||||
file => file.basename.match(/\.png|jpg|jpeg|gif|svg/gmi) !== [],
|
||||
imagemin()
|
||||
))
|
||||
.pipe(gulp.dest("dist/res"));
|
||||
return gulp.src("src/res/**/*.*").pipe(gulp.dest("dist"));
|
||||
};
|
||||
|
||||
exports.default = gulp.parallel(js, html, res);
|
||||
|
||||
exports.watch = () => {
|
||||
console.log("Transpiling current files...");
|
||||
js();
|
||||
html();
|
||||
res();
|
||||
console.log("Watching for changes!");
|
||||
console.log("Ready for changes!");
|
||||
gulp.watch(["src/**/*.js", "src/**/*.ts"], js);
|
||||
gulp.watch("src/*.html", html);
|
||||
gulp.watch("src/res/*", res);
|
||||
gulp.watch("res/**/*.*", res);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user