掌握 Gulp 并提出问题.
Getting to grips with Gulp and have a question.
所以我有一个类似下面的 gulp CSS 任务,它工作得很好:
So I have a gulp CSS task like the below which works just fine:
var sassDir = 'app/scss';
var targetCssDir = 'public/assets';
gulp.task('css', function(){
return gulp.src(sassDir + '/main.scss')
.pipe(sass({ style: 'compressed' }).on('error', gutil.log))
.pipe(autoprefix('last 10 version'))
.pipe(gulp.dest(targetCssDir));;
});
但是有没有办法像 Bootstrap 这样添加我的供应商文件,以便将其包含在内以进行缩小和连接.
But is there a way to add my vendor files like Bootstrap so it will be included for minification and concatenation.
希望你能给点建议!
gulp-sass 将满足您的要求.请让我向您展示如何编译 Sass 文件并缩小(或压缩)已编译的 css 文件:
gulp-sass will meet your request. Pls let me show you how to compile Sass files and minify (or compress) compiled css files:
注意:outputStyle 在 gulp-sass 中有四个选项:nested、expanded、compact、compressed
Note: outputStyle in gulp-sass has four options: nested, expanded, compact, compressed
它确实有效,我在我的项目中使用过它.希望对您有所帮助.
It really works, I have used it in my project. Hope it helps.
var gulp = require('gulp');
var sass = require('gulp-sass');
//sass
gulp.task('sass', function () {
gulp.src(['yourCSSFolder/*.scss', 'yourCSSFolder/**/*.scss'])
.pipe(sass({outputStyle: 'compressed'}))
.pipe(gulp.dest('yourCSSFolder/'));
});
// Default task
gulp.task('default', function () {
gulp.start('sass');
});
提醒一下自述文件
这篇关于使用 Gulp 编译 Sass 并缩小供应商 css的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
Browserify,Babel 6,Gulp - 传播运算符上的意外令牌Browserify, Babel 6, Gulp - Unexpected token on spread operator(Browserify,Babel 6,Gulp - 传播运算符上的意外令牌)
是否可以将标志传递给 Gulp 以使其以不同的方式Is it possible to pass a flag to Gulp to have it run tasks in different ways?(是否可以将标志传递给 Gulp 以使其以不同的方式运行任务
为什么我们需要在全局和本地安装 gulp?Why do we need to install gulp globally and locally?(为什么我们需要在全局和本地安装 gulp?)
如何一个接一个地依次运行 Gulp 任务How to run Gulp tasks sequentially one after the other(如何一个接一个地依次运行 Gulp 任务)
由于 MIME 类型而未加载样式表Stylesheet not loaded because of MIME-type(由于 MIME 类型而未加载样式表)
CSS3 过渡(供应商前缀)立即使 Safari 崩溃CSS3 Transition ( Vendor Prefixes) crashes Safari immediately(CSS3 过渡(供应商前缀)立即使 Safari 崩溃)