Why does gulp.src not like being passed an array of complete paths to files?

后端 未结 1 696
面向向阳花
面向向阳花 2020-11-29 19:53

I\'m attempting to pass gulp.src an array of files that I want it to deal with. This is the array as it stands.

[\'bower_components/jquery/jquery.js\',
 \'bo         


        
相关标签:
1条回答
  • 2020-11-29 20:18

    When you pass in an array of full paths, each file is processed independently. The globbing doesn't know where the root of the path is (in fact, it guesses based on the first glob). Therefore, each file is rooted in the folder it contains, and the relative path is empty.

    However, there is an easy solution. Pass an object with the key base as the second argument to gulp.src, and everything will have the correct relative path:

    return gulp.src(['bower_components/jquery/jquery.js',
                    'bower_components/superscrollorama/js/greensock/TweenMax.min.js',
                    'bower_components/superscrollorama/jquery.superscrollorama.js' ],
                {base: 'bower_components/'})
            .pipe(...);
    
    0 讨论(0)
提交回复
热议问题