ChrisV
ChrisV

Reputation: 241

Gulp rename and base path

I am searching for a solution allowing to modify the base part of path. I have a path like 'app/assets/theme/file.css' that i get with 'app/**/*.css' pattern and I would like to transform it to 'dist/assets/theme/file.css'.

For now I am doing something like:

gulp.src(paths.styles)
    .pipe(rename(function(path) {
        path.dirname = paths.dist + path.dirname;
    })

wich give me 'app/dist/assets/theme/file.css' instead of 'dist/assets/theme/file.css'. I don't find the way to erase 'app/' part.

How could I obtain the good result (using rename or another plugin if necessary) ?

Upvotes: 1

Views: 4091

Answers (2)

Lim H.
Lim H.

Reputation: 10050

There is a base option in gulp.src which you can use

gulp.src(paths.styles, {base: 'app'})
    .pipe(gulp.dest('dist'));

Read the doc for more details.

Upvotes: 3

Matt
Matt

Reputation: 1

You could try a String replace(), something like this:

gulp.src(paths.styles) .pipe(rename(function(path) { var newPath = paths.dist + path.dirname; path.dirname = newPath.replace('app/'); })

Upvotes: 0

Related Questions