我的gulpfile将已编译的css和js文件添加到dest(css / js)文件夹和src(scss / coffee)文件夹中。
所需的结果是已编译的文件仅打印到 dest文件夹。
这只发生在Windows上而不是Mac上运行gulp时。此外,如果我在没有手表的情况下运行任务,它会正确编译; 'gulp styles'仅将css文件编译到css文件夹 - 'gulp scripts'仅将js文件编译为js文件夹。
var gulp = require('gulp'),
plumber = require('gulp-plumber'),
rename = require('gulp-rename'),
autoprefixer = require('gulp-autoprefixer'),
coffee = require('gulp-coffee'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
minifycss = require('gulp-minify-css'),
sass = require('gulp-sass');
gulp.task('styles', function () {
return gulp.src(['scss/**/*.scss'])
.pipe(plumber({
errorHandler: function (error) {
console.log(error.message);
this.emit('end');
}
}))
.pipe(sass())
.pipe(autoprefixer('last 2 versions'))
.pipe(gulp.dest('css/'))
.pipe(rename({ suffix: '.min' }))
.pipe(minifycss())
.pipe(gulp.dest('css/'))
});
gulp.task('scripts', function () {
return gulp.src('coffee/**/*.coffee')
.pipe(plumber({
errorHandler: function (error) {
console.log(error.message);
this.emit('end');
}
}))
.pipe(coffee({ bare: true }))
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(gulp.dest('js/'))
.pipe(rename({ suffix: '.min' }))
.pipe(uglify())
.pipe(gulp.dest('js/'))
});
gulp.task('default', function () {
gulp.watch("scss/**/*.scss", ['styles']);
gulp.watch("coffee/**/*.coffee", ['scripts']);
});
答案 0 :(得分:0)
This is because you are calling gulp.dest
twice once before minification and once after minification. Calling dest writes file to disk on the path provided.
If you just want minified versions
For Css
.pipe(autoprefixer('last 2 versions'))
.pipe(rename({ suffix: '.min' }))
.pipe(minifycss())
.pipe(gulp.dest('css/'))
For Js
pipe(jshint.reporter('default'))
.pipe(rename({ suffix: '.min' }))
.pipe(uglify())
.pipe(gulp.dest('js/'))
答案 1 :(得分:0)
You possibly could try adding a func processImage(image:UIImage) {
let screenWidth = UIScreen.mainScreen().bounds.size.width
let width:CGFloat = image.size.width
let height:CGFloat = image.size.height
let aspectRatio = screenWidth/width;
UIGraphicsBeginImageContextWithOptions(CGSizeMake(screenWidth, screenWidth), false, 0.0) // create context
let ctx = UIGraphicsGetCurrentContext()
CGContextTranslateCTM(ctx, 0, (screenWidth-(aspectRatio*height))*0.5) // shift context up, to create a sqaured 'frame' for your image to be drawn in
image.drawInRect(CGRect(origin:CGPointZero, size: CGSize(width:screenWidth, height:height*aspectRatio))) // draw image
let img = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
imageView.image = img
}
to the destination paths to help preserve the source path:
.
and
.pipe(gulp.dest('css/')) -> .pipe(gulp.dest('./css/'))