控制台日志和警报无效

时间:2015-08-20 19:04:59

标签: javascript jquery console gulp alert

由于某些原因,console.logalert()函数似乎无法在我的任何js文件中使用。

我正在使用gulp来连接和编译一组.js文件(下面是gulpfile.js)。我认为这就是问题所在,因为当我将警报或console.log投入HTML页面时,它们工作正常。

// 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();

1 个答案:

答案 0 :(得分:2)

解决了它,它是gulp-strip-debug。它删除了所有警报和console.logs。

评论说,一切正常。