项目中用到的scss的配置,记录一下,谁叫咱脑袋不行呢
var gulp = require('gulp');
var plugins = require('gulp-load-plugins')();
var del = require('del');
var paths = {
styles:['app/scss/**/*.scss'],
outSytles:'app/css/',
outSourcemaps:'app/css_sourcemaps',
images: ['images/**','oa/images/**']
};
var reloadOptions= {
port:8010,
host:'localhost',
basePath:'./app/',
start:true,
reloadPage:'oa/contacts.html'
};
gulp.task('scss',function(){
return gulp.src(paths.styles)
.pipe(plugins.changed(paths.outSytles))
.pipe(plugins.sourcemaps.init())
.pipe(plugins.sass({
outputStyle: 'compressed'
}))
.on("error", plugins.notify.onError(function (error) {
return "哎哟喂: " + error.message;
}))
.pipe(plugins.sourcemaps.write({includeContent: false}))
.pipe(plugins.autoprefixer({
browsers: ['>1%'],
cascade: false,
remove:false
}))
.pipe(plugins.sourcemaps.write())
// .pipe(plugins.rename({suffix: '.min'}))
.pipe(gulp.dest(paths.outSytles))
.pipe(plugins.notify({
title:'scss编译',
message:'编译完成,没报错就成功...',
onLast:true
}))
.pipe(plugins.livereload());
});
gulp.task('watch', function() {
gulp.watch(['app/**']).on('change', plugins.livereload.changed);
gulp.watch(paths.styles, ['scss']);
plugins.livereload.listen(reloadOptions);
});
// 清除css文件夹
gulp.task("css_clear", function() {
del([paths.outSytles + '/**','!weui.min.css'])
})
gulp.task('default',['watch','scss']);
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。