与legacy.js有关的gulp-sourcemaps错误

时间:2017-06-27 16:07:03

标签: javascript npm gulp gulp-sourcemaps

您好我正在尝试为我的CSS创建sourceMap。我给了sass文件。我的任务完美无缺,但是当我添加sourcemap.init et sourcemap.Write时出现错误

这是我的任务

gulp.task('sass', function() {
  // Initialize
  var scssFilesToProcess = [{
    'inputFile': 'main.scss',
    'outputFile': 'main.min.css'
  }, {
    'inputFile': 'old_version_compatibility.scss',
    'outputFile': 'old_v_compat.min.css'
  }
  ];

  // Process files
  return scssFilesToProcess.map(function (scssFile) {
    return gulp.src(config.sassDir + '/' + scssFile.inputFile)
        .pipe(sass({
          includePaths: [
            config.bowerDir + '/bootstrap-sass/assets/stylesheets',
            config.sassDir
          ],
          outputStyle: (isProductionEnv ? 'compressed' : 'compact')
        }))
        .on('error', sass.logError)
        .pipe(sourcemaps.init({largeFile: true}))
          .pipe(gulpif(isProductionEnv, cleanCSS({
            compatibility: 'ie8'
          })))
          .pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9'))
          .pipe(concat(scssFile.outputFile))
          .pipe(rev())
        .pipe(sourcemaps.write('../maps/css'))
        .pipe(gulp.dest(config.webDir + '/css'))
        .pipe(filesize())
        .pipe(rev.manifest())
        .pipe(gulp.dest('build/assets/'+scssFile.outputFile+'-rev'))
        ;
  });
});

这是我得到的错误

internal/streams/legacy.js:59
      throw er; // Unhandled stream error in pipe.
      ^

Error: Invalid arguments
    at filesize (/var/www/wlz/node_modules/filesize/lib/filesize.js:34:9)
    at /var/www/wlz/node_modules/gulp-filesize/index.js:13:31
    at wrappedMapper (/var/www/wlz/node_modules/map-stream/index.js:83:19)
    at Stream.stream.write (/var/www/wlz/node_modules/map-stream/index.js:95:21)
    at DestroyableTransform.ondata (internal/streams/legacy.js:16:26)
    at emitOne (events.js:96:13)
    at DestroyableTransform.emit (events.js:188:7)
    at DestroyableTransform.<anonymous> (/var/www/wlz/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_readable.js:786:14)
    at emitNone (events.js:86:13)
    at DestroyableTransform.emit (events.js:185:7)

0 个答案:

没有答案