Closed binarykitchen closed 8 years ago
Negate removed matches from the glob. What you've specified here is "from no selected files, ignore everything that ends with map." Add a positive match first.
@robrich Thanks but I'm sorry I do not understand ...
Bad: .pipe(gulpIf('!*.map', autoprefixer()))
Good: .pipe(gulpIf(['', '!.map'], autoprefixer()))
Bad says "Pick nothing and also don't pick map."
Ah, I see. Many thanks!
@robrich Hello again. I experience issues again. Somehow the following does not work:
.pipe(gulpIf(['*.scss', '*.css'], autoprefixer(
...
)))
It does not process files ending with .scss or .css at all. How can I achieve this OR combination?
'*.css': CSS files in the current directory
'/.css': CSS files in any child directory one level deep
'*/.css': CSS files in any child directory recursively including the current one
Thanks but I meant, how to test for two different extensions?
Something like
if ('*.scss' or '*.css') then autoprefix()
That OR combination ... how do you do this with gulpIf?
gif(['.css','.scss'], autoprefixer())
No, this doesn't work. I tried various combinations:
cssTransform = (filename, sources) ->
gulp.src(sources)
.pipe(gulpIf('*.scss', rubySass(config.sass)))
.pipe(gulpIf(['*.css', '*.scss'], autoprefixer(
'> 1%'
'last 5 versions'
'Firefox ESR'
)))
.pipe(concat(filename))
.pipe(gulpIf(config.compress, minifyCSS()))
.pipe(gulp.dest("#{paths.public}/styles"))
.pipe(tap(logFile))
Like that the autoprefixer won't process CSS files.
But if I change to
.pipe(gulpIf('*.css', autoprefixer(
'> 1%'
'last 5 versions'
'Firefox ESR'
)))
then CSS files only become autprefixed.
Somehow gif(['*.css','*.scss'], autoprefixer())
is not working. A bug?
Interesting. Do you have a pastebin or a github link?
I'm afraid, it's a private project. But can you please add the above scenario to your unit tests? A glob with two different file types (OR combination).
On what line? I do not see the same scenario
I'm trying to concat dist scripts (the minified files from each lib) with the result of uglify
on the one that aren't minified.
I got a list af scripts such as:
var bower = {
scripts_vendor: [
'bower_components/ng-breadcrumbs/dist/ng-breadcrumbs.min.js',
'bower_components/d3/d3.min.js',
'bower_components/bootstrap/dist/js/bootstrap.min.js',
'bower_components/ui.bootstrap/src/position/position.js',
'bower_components/ui.bootstrap/src/progressbar/progressbar.js'
]
}
and a task as:
gulp.task('scripts_vendor', function () {
return gulp.src(bower.scripts_vendor)
.pipe(gulpif(/ui\.bootstrap/, uglify({mangle: false})))
.pipe(concat('vendor.min.js'))
.pipe(gulp.dest('../static/js'));
});
This works but look awkard as it may be difficlut to maintain.
I tried to use !/min/
at first but it doesn't minify the non-minified files.
/min/
pass, otherwise uglify?From the docs at https://github.com/robrich/gulp-if: use a condition function.
var gulpif = require('gulp-if');
var uglify = require('gulp-uglify');
var beautify = require('gulp-beautify');
var condition = function (file) {
// TODO: add business logic
return true;
}
gulp.task('task', function() {
gulp.src('./src/*.js')
.pipe(gulpif(condition, uglify(), beautify()))
.pipe(gulp.dest('./dist/'));
});
does not work. How can I skip the autoprefixer when the file ends with
*.map
?