Using variables in Gulp for the destination file name?

后端 未结 2 1526
栀梦
栀梦 2021-02-05 16:03

I am new to gulp and I am wondering if what I want to achieve is practical or possible.

My projects structure:

root
|
components
|   |
|   component_1
|          


        
2条回答
  •  爱一瞬间的悲伤
    2021-02-05 16:19

    Old question i know, but i been playing around in this area today, and hence came across this question. This may help someone if you are wanting to do something dynamic with the destination path.

    You can supply a function as the argument to gulp.dest and hence do some pre processing on the destination path like this:

    .pipe(gulp.dest(function (file) {
        // file is the current file in the stream
        // do something here               
        return pathString;
    }));
    

提交回复
热议问题