如果Gulp观看时CSS文件中有问题,我想听到声音,因此我尝试安装beepbeep。但是我该如何使用呢?看起来很简单,但也许我在其他地方不见了。
以下是gulpfile.js的内容-程序包,配置和CSS任务(类似于https://github.com/floatdrop/gulp-plumber/issues/38)。其他一切都很完美
// Packages
const gulp = require('gulp');
const sass = require('gulp-sass');
const plumber = require('gulp-plumber');
const cleanCSS = require('gulp-clean-css');
const autoprefixer = require('gulp-autoprefixer');
const combineMq = require('gulp-combine-mq');
const uglify = require('gulp-uglify');
const sourcemaps = require('gulp-sourcemaps');
const notify = require('gulp-notify');
const prettyError = require('gulp-prettyerror');
const watch = require('gulp-watch');
const beep = require('beepbeep');
const size = require('gulp-size');
// For displaying size of compiled css
let s = size();
const notifyConfig = {
onLast: true,
message: () => `CSS completed! - Total size ${s.prettySize}`
}
// On error function
const onError = function (err) {
notify.onError({
title: "gulp error in " + err.plugin,
message: err.toString()
})(err);
beep(2);
this.emit('end');
};
// Task for CSS
gulp.task('css', function () {
s = size();
return gulp.src(cssMainFile)
.pipe(prettyError())
.pipe(plumber({
errorHandler: onError
}))
.pipe(sass(sassConfig))
.pipe(autoprefixer(autoPrefixerConfig))
.pipe(combineMq({
beautify: false
}))
.pipe(cleanCSS({
compatibility: 'ie9',
keepSpecialComments: false
}))
.pipe(s)
.pipe(gulp.dest(cssDestinationFolder))
.pipe(notify(notifyConfig));
});
我还打开了test.js
文件,并尝试使用node test.js
运行该文件,但听不到任何声音。我在Windows 10上,系统声音设置为最大
var beep = require('beepbeep');
beep(2);