Answer the question
In order to leave comments, you need to log in
Gulp-rename how to rename a specific file from multiple?
Hello everyone .. I did the following task ... I wanted the SCSS files to first be compiled into the CSS folder (for myself), and then only one main file was minified, renamed and thrown into the APP / CSS folder ... but everything is renamed and thrown files..
For example , after compilation, the following files are obtained: one.css, two.css, styles.css
How to properly configure so that only the main styles.css file is further minified, renamed to the APP / CSS folder.
Here is a task so far:
var gulp = require('gulp'),
cleanCSS = require('gulp-clean-css'),
rename = require("gulp-rename"),
prefixer = require('gulp-autoprefixer'),
livereload = require('gulp-livereload'),
connect = require('gulp-connect'),
sass = require('gulp-sass');
gulp.task('css', function () {
return gulp.src('scss/*.scss')
.pipe(sass())
.pipe(prefixer({
overrideBrowserslist: ['last 2 versions', '> 0.5%'],
cascade: false
}))
.pipe(gulp.dest('css/'))
.pipe(cleanCSS({level: 2}))
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('app/css'))
.pipe(connect.reload());
});
Answer the question
In order to leave comments, you need to log in
From the documentation https://www.npmjs.com/package/gulp-rename
// rename via function
gulp.src("./src/**/hello.txt")
.pipe(rename(function (path) {
path.dirname += "/ciao";
path.basename += "-goodbye";
path.extname = ".md";
}))
.pipe(gulp.dest("./dist")); // ./dist/main/text/ciao/hello-goodbye.md
if( path.basename.math(/^styles/i) ) { path.dirname += "/ciao"; }
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question