我的gulpfile有问题。当我执行任务时它的工作但不编译任何css文件。
这是我的gulpfile:
var gulp = require('gulp'),
sass = require('gulp-sass'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
min = require('gulp-clean-css'),
tar = require('gulp-tar'),
gzip = require('gulp-gzip'),
watch = require('gulp-watch'),
util = require('gulp-util');
var PATH_JS_SRC = 'src/main/webapp/frontend/js/',
PATH_CSS_SRC = 'src/main/webapp/frontend/src/scss/',
PATH_CSS_DIST = 'src/main/webapp/styles/';
gulp.task('default', function(){
});
gulp.task('scripts', function(){
});
gulp.task('sass', function(){
gulp.src(PATH_CSS_SRC + 'main.scss')
.pipe(sass({ outputStyle: "compressed" }).on('error', sass.logError))
.pipe(concat('app.css'))
.pipe(min({ compatibility: 'ie8' }))
.pipe(gulp.dest(PATH_CSS_DIST));
});
我做错了什么?任何建议?
答案 0 :(得分:1)
您可以尝试在最后一个gulp任务中交换2行。我们先把 .pipe(concat('app.css'))放在 .pipe(sass(...))之前
var gulp = require('gulp'),
sass = require('gulp-sass'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
min = require('gulp-clean-css'),
tar = require('gulp-tar'),
gzip = require('gulp-gzip'),
watch = require('gulp-watch'),
util = require('gulp-util');
var PATH_JS_SRC = 'src/main/webapp/frontend/js/',
PATH_CSS_SRC = 'src/main/webapp/frontend/src/scss/',
PATH_CSS_DIST = 'src/main/webapp/styles/';
gulp.task('default', function(){
});
gulp.task('scripts', function(){
});
gulp.task('sass', function(){
gulp.src(PATH_CSS_SRC + 'main.scss')
.pipe(concat('app.css'))
.pipe(sass({ outputStyle: "compressed" }).on('error', sass.logError))
.pipe(min({ compatibility: 'ie8' }))
.pipe(gulp.dest(PATH_CSS_DIST));
});