如何修复未处理的“错误”事件,在使用Gulp时,“A”的@导入声明被破坏?

lymgl2op  于 2022-12-08  发布在  Gulp
关注(0)|答案(1)|浏览(150)

我一直很高兴地使用gulp.js进行编译,但今天下午我开始收到这样的错误:

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: Broken @import declaration of "A"

我的gulpfile.js看起来像这样:

var gulp = require('gulp'),
    minifyCSS = require('gulp-minify-css'),
    sass = require('gulp-ruby-sass'),
    imagemin = require('gulp-imagemin')
    minifyHTML = require('gulp-minify-html'),
    uglify = require('gulp-uglify'),
    fileinclude = require('gulp-file-include');

gulp.task('sass', function() {
    return sass('node_modules/foundation/scss/') 
    .on('error', function (err) {
      console.error('Error!', err.message);
   })
    .pipe(gulp.dest('publish/css'));
});

gulp.task('image', function(){
    gulp.src('images/*')
    .pipe(imagemin())
    .pipe(gulp.dest('publish/images'));
});

gulp.task('fileinclude', function() {
  gulp.src(['index.html'])
    .pipe(fileinclude({
      prefix: '@@',
      basepath: '@file'
    }))
    .pipe(gulp.dest('./html/'));
});

gulp.task('minify-css', function() {
  gulp.src('publish/css/*.css')
    .pipe(minifyCSS({keepBreaks:false}))
    .pipe(gulp.dest('publish/css'));
});

gulp.task('compress', function() {
  return gulp.src(['./node_modules/foundation/js/foundation/*.js','./node_modules/foundation/js/vendor/*.js'])
    .pipe(uglify())
    .pipe(gulp.dest('publish/js'));
});

gulp.task('minify-html', function() {
  var opts = {
    conditionals: true,
    spare:true
  };

  return gulp.src('./html/*.html')
    .pipe(minifyHTML(opts))
    .pipe(gulp.dest('./publish/'));
});

gulp.task('watch', function(){
    gulp.watch('node_modules/foundation/scss/', ['sass']);
    gulp.watch('publish/css/*', ['minify-css']);
    gulp.watch('publish/images/*', ['image']);
});

gulp.task('alpha', [ 'sass','fileinclude','minify-css','image','compress' ]);

gulp.task('omega', ['minify-html']);

gulp.task('build', ['alpha', 'omega']);

gulp.task('default', ['build']);

我已经重新启动,尝试检查端口冲突和谷歌这详尽。
有人能看出可能导致此问题的明显问题吗?
编辑:我应该补充一点,我使用的是Foundation框架。

rbpvctlc

rbpvctlc1#

gulp-minify-css软件包是我的罪魁祸首。我把这个参数添加到我的gulpfile.js文件中,它修复了这个问题:

processImport: false

例如:

.pipe(plugins.minifyCss({ keepSpecialComments: 1, processImport: false }))

相关问题