gulp编译sass文件报错
每次更改或者删除写完的CSS就会这样,求救啊?
完整的gulpfile.js
var gulp = require('gulp'),
plugins = require('gulp-load-plugins')(),
runSequence = require('run-sequence'),
browserSync = require('browser-sync').create(),
reload = browserSync.reload;
var path = './src/',
csspath = './src/css/**/*.css',
sasspath = './src/sass/**/*.scss',
jspath = './src/js/**/*.js' ;
var disPath = './dist/',
disCssPath = './dist/css/',
disJsPath = './dist/js/';
gulp.task("default",['clean'],function(){
runSequence(['serve']);
console.log("gulp启动成功");
});
gulp.task('clean', function () {
gulp.src([disPath,csspath])
.pipe(plugins.clean())
});
gulp.task('sassToCss',function(){
plugins.rubySass(sasspath, {style: 'expanded'})
.pipe(plugins.autoprefixer({browsers:['last 2 versions']}))
.pipe(gulp.dest('./src/css/'))
.pipe(reload({stream: true}));
});
gulp.task('cssToCss', function () {
gulp.src("./src/sass/**/*.css")
.pipe(plugins.autoprefixer({browsers:['last 2 versions']}))
.pipe(gulp.dest('./src/css/'))
.pipe(reload({stream: true}));
});
gulp.task('minicss',function(){
plugins.rubySass(sasspath, {style: 'expanded'})
.pipe(plugins.autoprefixer({browsers:['last 2 versions']}))
.pipe(gulp.dest(disCssPath))
.pipe(plugins.rename({suffix:'.min'}))
.pipe(plugins.cssnano())
//.pipe(plugins.concat(all.css))
.pipe(gulp.dest(disCssPath))
});
gulp.task("minijs",function(){
gulp.src(jspath)
//.pipe(plugins.concat('all.js'))
.pipe(gulp.dest(disJsPath))
.pipe(plugins.uglify())
.pipe(plugins.rename({suffix:".min"}))
.pipe(gulp.dest(disJsPath))
});
gulp.task('miniimage',function(){
gulp.src('src/images/**/*.*')
.pipe(plugins.imagemin())
.pipe(gulp.dest('dist/images/'))
});
gulp.task('copy',function(){
gulp.src(['./src/**/*.*'])
.pipe(gulp.dest('./dist/'));
});
gulp.task('build',['clean'],function(){
gulp.start('copy,','cssToCss','minicss','minijs','miniimage');
console.log('build end');
});
gulp.task('serve',['cssToCss','sassToCss'],function() {
var htmlFiles = './src/**/*.html';
browserSync.init({
directory:true,
server : './src',
port: 3333
});
gulp.watch(sasspath, ['sassToCss']);
gulp.watch('src/**/*.html').on('change',reload);
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我遇到过这个问题,当时我实在webstrom下,配置sass进行编译的,不过忘记怎么解决的了,似乎是因为自己写的sass不规范,有语法错误导致的。