For some reason console.log
and alert()
functions don't seem to be working across any of my js files.
I'm using gulp to concatenate and compile a set of .js files ( gulpfile.js
below). I think this is where the problem lies as when I throw an alert or a console.log into an HTML page, they work fine.
// include gulp
var gulp = require('gulp');
// --------------------------------------------------------------
// Plugins
// ---------------------------------------------------------------
var concat = require('gulp-concat');
var stripDebug = require('gulp-strip-debug');
var uglify = require('gulp-uglify');
var include = require('gulp-include');
var sass = require('gulp-sass');
var minifycss = require('gulp-minify-css');
var watch = require('gulp-watch');
var livereload = require('gulp-livereload');
var changed = require('gulp-changed');
//var notify = require('gulp-notify');
//var plumber = require('gulp-plumber');
// --------------------------------------------------------------
// JS
// ---------------------------------------------------------------
gulp.task('scripts', function() {
gulp.src(['./js/script.js'])
.pipe(include())
.pipe(concat('script-dist.js'))
.pipe(stripDebug())
.pipe(uglify())
.pipe(gulp.dest('./js/'))
.pipe(livereload());
});
// --------------------------------------------------------------
// Sass
// ---------------------------------------------------------------
gulp.task('styles', function() {
gulp.src('./ui/scss/styles.scss')
.pipe(include())
.pipe(sass({
errLogToConsole: true
}))
.pipe(minifycss())
.pipe(gulp.dest('./ui/css/'))
.pipe(livereload());
//.pipe(plumber({errorHandler: notify.onError("Error: <%= error.message %>")}))
//.pipe(through(function () {
// this.emit("error", new Error("Something happened: Error message!"))
//}));
});
// --------------------------------------------------------------
// Watch & Reload
// ---------------------------------------------------------------
gulp.task('watch', function() {
gulp.watch('./ui/scss/*.scss', ['styles']);
gulp.watch(['./js/*.js', '!./js/vendor/**', '!./js/script-dist.js'], ['scripts']);
});
gulp.task('default', ['styles', 'watch']);
gulp.task('default', ['scripts', 'watch']);
livereload.listen();
Solved it, it was gulp-strip-debug
. It strips out all alerts and console.logs.
Commented that out and everything works fine.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.