有没有人收到此类错误或者可以告诉我这里发生了什么?
[11:11:44] Finished 'build-css-no-source' after 531 ms
[11:11:44] Starting 'move-to-dist'...
/Users/username/Sites/my_site/node_modules/gulp-iconfont/node_modules/gulp-ttf2woff2/node_modules/ttf2woff2/jssrc/ttf2woff2.js:1
aughtException",(function(ex){if(!(ex instanceof ExitStatus)){throw ex}}));Mod
^
Error: write after end
at writeAfterEnd (/Users/username/Sites/my_site/node_modules/gulp-uglify/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:191:12)
at DestroyableTransform.Writable.write (/Users/username/Sites/my_site/node_modules/gulp-uglify/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:236:5)
at Stream.ondata (stream.js:51:26)
at Stream.emit (events.js:95:17)
at Stream.endStream (/Users/aaronirons/Sites/haven_shopify/node_modules/gulp-usemin/node_modules/gulp-concat/index.js:90:10)
at _end (/Users/username/Sites/my_site/node_modules/gulp-usemin/node_modules/gulp-concat/node_modules/through/index.js:65:9)
at Stream.stream.end (/Users/username/Sites/my_site/node_modules/gulp-usemin/node_modules/gulp-concat/node_modules/through/index.js:74:5)
at Transform.onend (/Users/username/Sites/my_site/node_modules/gulp-usemin/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:523:10)
at Transform.g (events.js:180:16)
at Transform.emit (events.js:117:20)
at /Users/username/Sites/my_site/node_modules/gulp-usemin/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:965:16
at process._tickCallback (node.js:419:13)
这个项目以前组装得很好,但现在它似乎随意地在dist构建上窒息。
我正在使用Node 0.10.33。
这是我的gulp文件:
var gulp = require('gulp');
var sass = require('gulp-sass');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
var notify = require('gulp-notify');
var prefix = require('gulp-autoprefixer');
var usemin = require('gulp-usemin');
var uglify = require('gulp-uglify');
var minifyCSS = require('gulp-minify-css');
var gutil = require('gulp-util');
var rename = require("gulp-rename");
var iconfont = require('gulp-iconfont');
var iconfontCss = require('gulp-iconfont-css');
var fontName = 'Icons';
var cache = require('gulp-cache');
// var spritesmith = require('gulp.spritesmith');
var fs = require('fs');
var fileinclude = require('gulp-file-include');
//var sourcemaps = require('gulp-sourcemaps');
// var newer = require('gulp-newer');
var imagemin = require('gulp-imagemin');
//needed becaues current gulp-sass errors with source maps on windows
var processWinPath = function(file) {
var path = require('path');
if (process.platform === 'win32') {
file.path = path.relative('.', file.path);
file.path = file.path.replace(/\\/g, '/');
}
};
gulp.task("build-css", function() {
return gulp.src('src/scss/main.scss')
.on('data', processWinPath)
// .pipe(sourcemaps.init())
.pipe(sass({
errLogToConsole: false,
includePaths: ['./src/bower_components/foundation/scss/'],
onError: function callback(err) {
return notify().write(err);
}
}))
// .pipe(sourcemaps.write())
.pipe(gulp.dest('src/css/'));
});
gulp.task("build-css-no-source", function() {
return gulp.src('src/scss/main.scss')
.pipe(sass({
errLogToConsole: true,
includePaths: ['./src/bower_components/foundation/scss/'],
onError: function(err) {
return notify().write(err);
}
}))
.pipe(prefix())
.pipe(gulp.dest('src/css/'));
});
gulp.task('default', function() {
browserSync({
server: {
baseDir: "./src/"
},
files: ['src/*.html', 'src/css/*.css', 'src/js/*.js']
});
//run fileinclude on html changes
gulp.watch(['*.html', 'includes/*.html'], ['fileinclude']);
//compile css on sass changes
gulp.watch(['src/scss/*.scss'], ["build-css"]);
//need to figure out cert issue
//gulp.watch(["img/*.jpg", "img/*.png", "img/*.gif", "img/*.jpeg"], ["compress-images"]);
});
gulp.task('fileinclude', function() {
gulp.src('*.html')
.pipe(fileinclude({
prefix: '@@',
basepath: '@file'
}))
.pipe(gulp.dest('./src'));
});
gulp.task('build', ['build-css-no-source', 'move-to-dist', 'minify-css']);
gulp.task('move-to-dist', ['build-css-no-source'], function() {
var stream = gulp.src('src/*.html')
.pipe(usemin({
// assetsDir:"./src/",
css: ['concat'],
js: [uglify()],
jsmain: []
}))
.pipe(gulp.dest('dist/'));
gulp.src('src/fonts/**')
.pipe(gulp.dest('dist/fonts/'));
gulp.src('src/img/**')
.pipe(gulp.dest('dist/img/'));
gulp.src('src/js/main.js')
.pipe(gulp.dest('dist/js/'))
return stream;
});
gulp.task('minify-css', ['move-to-dist'], function() {
fs.readFile('./dist/css/styles.css', function(err, data) {
if (err) throw err;
var content = data.toString();
var index = content.indexOf("/* split file here */");
var vendor = content.slice(0, index);
var main = content.slice(index);
fs.writeFile('./dist/css/styles.css', main, function(err) {
if (err) throw err;
console.log('main is saved!');
});
fs.writeFile('./dist/css/vendor.min.css', vendor, function(err) {
if (err) throw err;
console.log('vendor is saved!');
return gulp.src('./dist/css/vendor.min.css')
.pipe(minifyCSS())
.pipe(gulp.dest('./dist/css/'));
});
});
});
//run once after project has been created
gulp.task('init', function() {
//move slick from bower components into project
gulp.src('/bower_components/slick-carousel/slick/slick.scss')
.pipe(gulp.dest('src/scss'));
gulp.src('/bower_components/foundation/scss/foundation/_settings.scss')
.pipe(gulp.dest('src/scss'));
});
gulp.task('make-iconfont', function() {
gulp.src(['svg/*.svg'])
.pipe(iconfontCss({
fontName: fontName,
fontPath: '../fonts/',
targetPath: '../scss/_icons.scss'
}))
.pipe(iconfont({
fontName: fontName,
fontHeight: 1000,
appendCodepoints: true,
normalize: true
}))
.pipe(gulp.dest('src/fonts/'));
});
var generateIconImport = function(inputfile) {
fs.readFile(inputfile, function(err, data) {
if (err) throw err;
var content = data.toString();
var html = "<div class='row icon-testing'><div class='small-12 columns'>";
var re = /(icon\-\w.*(?=:))/g;
var matches = content.match(re);
matches.forEach(function(item) {
html += "<div class='icon " + item + "'> " + item + "</div>";
});
console.log(html);
fs.writeFile('src/fonts/icons.html', html + '</div></div>', function(err) {});
});
}
gulp.task('view-iconfont', function() {
generateIconImport("src/scss/_icons.scss");
});
gulp.task('clear', function (done) {
return cache.clearAll(done);
});
请帮忙!这快要让我发疯了!