- This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
Viewing 6 posts - 1 through 6 (of 6 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › Gulp/Grunt Question
Pretty sure it’s the same in both packages.
How do I use variables for file names?
For instance, if I have:
file1.js
file2.js
file3.js
And I want to give that a destination of:
file1.min.js
file2.min.js
file3.min.js
return gulp.src('js/file1.js')
.pipe(uglify())
.pipe(concat('file1.min.js'))
.pipe(gulp.dest('js/build'));
Without having to rewire this 3 different times with the 3 different file names.
Just use the *
as a wild-card and you’re good.
return gulp.src('js/*.js)
I thought that would work, but it just takes all of the files and runs them into *.js
You can use an array like this
gulp.src([‘file1.js’, ‘file2.js’]).pipe(…)
If you want you can take a look on my gulpfile
https://github.com/maxisix/maxisix-gulp-template/blob/master/gulpfile.js
If you haven’t already check out the gulp-rename plugin.